我正在开发vb.net窗口应用程序。如何在设计时在vb.net中设置DataGridView中dd-MMM-yy的日期格式?
我已经使用网格视图来显示数据。
我想在DataGridView
中使用dd-MMM-yy
格式。
例如,我想显示的时间为01-JAN-16
,但我不能看到在VS 2012 IDE的这种格式。
这里是它的形象...
我可以使用自定义格式呢?它的格式是什么?
我正在开发vb.net窗口应用程序。如何在设计时在vb.net中设置DataGridView中dd-MMM-yy的日期格式?
我已经使用网格视图来显示数据。
我想在DataGridView
中使用dd-MMM-yy
格式。
例如,我想显示的时间为01-JAN-16
,但我不能看到在VS 2012 IDE的这种格式。
这里是它的形象...
我可以使用自定义格式呢?它的格式是什么?
您可以在设计或运行时使用DataGridViewCellStyle.Format
属性将格式设置为dd-MMM-yy
。然后它显示日期为06-Jan-16
。
转至Columns
属性,并打开Edit Columns
窗口。在Appearance
类别下,编辑DefaultCellStyle
,打开CellmStyle Builder
窗口并在Behavior
类别下输入自定义Format
。
您也可以在...
点击并打开Format String Dialog
和预定义格式和自定义格式之间进行选择,并输入有自定义格式:
或者使用代码,你可以这样写代码:
Dim DataGridViewCellStyle1 = New DataGridViewCellStyle()
DataGridViewCellStyle1.Format = "dd-MMM-yy"
Me.Column1.DefaultCellStyle = dataGridViewCellStyle1
欲了解更多信息关于可以使用Format
属性的支持格式,请参见Formatting Types in the .NET Framework。