如何在数据网格视图中更改特定列的日期格式 [英] How Do I Change Date Format For Particular Column In Data Grid View

查看:84
本文介绍了如何在数据网格视图中更改特定列的日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有一个要求,即特定列(DataGridView中的日期时间列)是mm / dd / yyyy(任何格式)格式。



点击按钮后,它应打开另一个表格,要求更改多种格式(例如:mm / dd / yyyy到dd / mm / yyyy, mm / dd / yyyy到yyyy / mm / dd,dd / mm / yyyy到mm / dd / yyyy)。



选择特定格式并点击提交后(按钮),更改应反映在列(在表单1上)。



请帮我编程。我想在C#.net获得帮助。



提前致谢。

解决方案

使用 Column.DefaultCellStyle.Format [ ^ ] 还有 [ ^ ]属性:

 myDGV.Columns [  MyDateColumn ]。DefaultCellStyle.Format =   dd / MM / yyyy; 


Hi,

I have a requirement where a particular column (Date Time column in DataGridView) is in mm/dd/yyyy (any format) format.

After clicking on a button, it should open another form where it should ask for multiple formats to change (Ex: mm/dd/yyyy to dd/mm/yyyy, mm/dd/yyyy to yyyy/mm/dd, dd/mm/yyyy to mm/dd/yyyy).

After selecting particular format and clicking on submit (Button), the changes should reflect on the column (which is on Form 1).

Please help me on programming this. I would like to get help in C#.net.

Thanks in advance.

解决方案

Use the Column.DefaultCellStyle.Format[^] and also[^] property:

myDGV.Columns["MyDateColumn"].DefaultCellStyle.Format = "dd/MM/yyyy";


这篇关于如何在数据网格视图中更改特定列的日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆