且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Windows应用程序中的datagridview中格式化日期时间

更新时间:2023-01-28 23:19:13

当我尝试使用dataGridView时,它工作正常,提供日期信息I加载到DGV数据源实际上是一个DateTime值:如果它是一个日期的字符串表示,那么它就无法用它做任何事情。



检查你的数据源:如果它是一个DB,请确保源列是DATE或DATETIME,并且在检索信息时不要使用CONVERT对其进行格式化。
When I try that with a dataGridView, it works fine, provided the date information I have loaded into the DGV data source is actually a DateTime value: if it's a string representation of a date, then it can't do anything with it.

Check your data source: if it's a DB, make sure that the source column is DATE or DATETIME and that you don't format it with a CONVERT when you retrieve the information.