vb.net 如何将 Datagridview 中的格式列更改为此值的日期类型

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21749542/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 17:25:24  来源:igfitidea点击:

How to Change Format column in Datagridview to date type for this value

vb.netdatagridviewcolumn

提问by Muhammad Nafian Wildana

For example, I have a value like this :

例如,我有一个这样的值:

41607.2069444444; 41607.2068402778; 41607.2072222222;

this is calculation of dateTimeOrigination from CDR, in excel where i change the format cell to type date, its work and this is 11/29/2013 4:58:42 AM. My questions is how to format this value to date in datagridview in VB.net?

这是从 CDR 计算 dateTimeOrigination,在 excel 中,我将格式单元格更改为键入日期,它的工作,这是 11/29/2013 4:58:42 AM。我的问题是如何在 VB.net 的 datagridview 中将此值格式化为日期?

回答by Eldar Zeynalov

Try like this:

像这样尝试:

MyDatagridview.Columns(4).DefaultCellStyle.Format = "dd.MM.yyyy HH:mm:ss"

In my case the 5th column (Remember that Datagridview.Columns are zero-based) is Date-Type Let me know if it helped you :)

在我的情况下,第 5 列(请记住 Datagridview.Columns 是从零开始的)是 Date-Type 让我知道它是否对您有帮助:)