日期:2014-05-18  浏览次数:20896 次

DataGridView格式化时间的问题
代码如下:
dataGridView1.Columns["**"].DefaultCellStyle.Format=“HH:mm"

但是起不到作用,不知道什么原因~
请教各位!

------解决方案--------------------
可以的

C# code

            dataGridView.Columns[1].DefaultCellStyle.Format = "HH:mm";
            dataGridView.Rows.Add(new object[] { 2, DateTime.Now, 3 });
            dataGridView.Rows.Add(new object[] { 5, DateTime.Now, 6 });
            dataGridView.Rows.Add(new object[] { 8, DateTime.Now, 9 });

------解决方案--------------------
Assembly code
Formating the Date 

To Format as dd/MM/yyyy is     this.dgView.Columns["Inv/Ch Date"].DefaultCellStyle.Format = "dd/MM/yyyy";
To Format as dd/MMM/yyyy is     this.dgView.Columns["Inv/Ch Date"].DefaultCellStyle.Format = "dd/MMM/yyyy";
To Format as dd-MMM-yyyy is     this.dgView.Columns["Inv/Ch Date"].DefaultCellStyle.Format = "dd-MMM-yyyy";