數據庫存中表的值為1803(字符串格式),要在DataGridTextBoxColumn列中將值由1803顯示成18:03格式,輸入時不需要輸入":"分隔符,並且保存時值中不能有":"分隔符.
請問,這個格式該如何設置,或者其它的方法.
用戶沒法接受1803的輸入格式,因為舊系統中pb的,可以設置成18:03的格式,但在C#的DataGridTextBoxColumn.Format中該如何設置呀?
我另外發了兩個貼子:
http://community.csdn.net/Expert/topic/5441/5441759.xml?temp=.1754419
http://community.csdn.net/Expert/topic/5445/5445199.xml?temp=.939831
始終沒有得到解決的方法.
如果有回複,請順便在另外兩貼回一下,以好給分.謝謝啦
請問,這個格式該如何設置,或者其它的方法.
用戶沒法接受1803的輸入格式,因為舊系統中pb的,可以設置成18:03的格式,但在C#的DataGridTextBoxColumn.Format中該如何設置呀?
我另外發了兩個貼子:
http://community.csdn.net/Expert/topic/5441/5441759.xml?temp=.1754419
http://community.csdn.net/Expert/topic/5445/5445199.xml?temp=.939831
始終沒有得到解決的方法.
如果有回複,請順便在另外兩貼回一下,以好給分.謝謝啦
解决方案 »
- 动态增加ToolStripButton时,窗体变化时消失
- 请教一个多线程的问题,对象加锁,有些地方不明白,高手帮忙看看
- 如何实现文件压缩
- udpclient 错误签名
- 如何给HtmlInput控件的onBlur属性注册javascript函数?
- c# 网页跳转问题!!
- SEO|搜索引擎优化(如何让你的网站排名靠前)
- 关于余数的问题
- 关于C#通过HttpWebRequest调用web api 接口post 传参的问题
- datagrid中增加一行时,所有单元都显示(空),如何让它不显示这个字
- C#如何实现在textBox1上敲回车时光标跳至button2 ?
- 关于XPath(不知道在哪问了,暂时放这儿:-))
{
return myTime.substring(0,2)+":"+myTime.substring(2,2);
}
Dim myString As String = myDouble.ToString( "(###) ### - ####" )
this.Label1.Text=url.ToString("##:##");
这个好使,我试过了
楼上的那样可以
.ToString("##:##");
我想說明一點是的:
1.DataGridTextBoxColumn綁定列的類型是字符型
2.是DataGridTextBoxColumn的Format屬性該如何設置,或者是在DataGrid中如何控件1806顯示和輸入時為18:06的格式,而不是ToString()方法.
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{
this.dataGridView1.Rows.Add("1083");
this.dataGridView1.Columns[0].DefaultCellStyle.FormatProvider = new fmt();
}
} public class fmt : IFormatProvider, ICustomFormatter
{
#region IFormatProvider Members public object GetFormat(Type formatType)
{
if (argType == typeof(ICustomFormatter))
return this;
else
return null;
} #endregion #region ICustomFormatter Members public string Format(string format, object arg, IFormatProvider formatProvider)
{
//这里写上你自己的格式化代码
} #endregion
}
}这样就可以了!
具体的还是去多看看MSDN!
我几乎每天能看到这个名字N次 强人啊
{
#region IFormatProvider Members public object GetFormat(Type formatType)
{
if (argType == typeof(ICustomFormatter))
return this;
else
return null;
} #endregion #region ICustomFormatter Members public string Format(string format, object arg, IFormatProvider formatProvider)
{
//这里写上你自己的格式化代码
} #endregion
}this.dataGridTextBoxColumn1.FormatInfo =new fmt();
靠,原来就是这么简单!!!
楼主可以结贴了!