數據庫存中表的值為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
始終沒有得到解決的方法.
如果有回複,請順便在另外兩貼回一下,以好給分.謝謝啦
解决方案 »
- 水晶报表问题!!!!
- 关于应用程序中的静态变量
- vs2005中有没有一个功能监测某个事件触发 其关联了多少函数和过程
- Freetextbox text属性 是什么实现的?
- (急)C#做COM组件,如何把常量也像接口函数一样提供给使用者
- 如何显示DataRowCollection、如何加入DataTable的简单问题,非常感谢。
- (c#asp.net)请帮忙了!!!!想在datagrid里实现鼠标单击某行使改行变成颜色。
- 请问C#有没有换肤控件?请各位提供一下。
- ████████【网络编程】文件传输线程与内存,恭请思归,孟子E章,Herry和海波三位大侠及其他星级及角级既无级高手入内!
- (高手赐教)怎么做菜单编辑器?
- 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();
靠,原来就是这么简单!!!
楼主可以结贴了!