固定在datagridveiw或数据集中的日期格式 [英] Date format fixed in datagridveiw or dataset
问题描述
开发者
我的csv文件包含日期格式为23.4.2010 as dd.mm.yyy
,但是我希望日期格式可以像这样23/4/2010 as mm/dd/yyyy
Hi developer
My csv file contain the date format as 23.4.2010 as dd.mm.yyy
but I want that a date format can be like this 23/4/2010 as mm/dd/yyyy
Datagidview1= System.Globalization.DateTimeFormatInfo.CurrentInfo.DateSeparator
或
or
Datagridview1.Columns[7].DefaultCellStyle.Format = System.Globalization.DateTimeFormatInfo.CurrentInfo.ShortDatePattern;
此代码不起作用
我想采用一种适用于包含日期的所有列的格式.并且在加载csv文件时,将自动应用日期格式.不在索引号上.因为我不再有信心所有值始终位于其特定的单元格位置.
所以请通过解决此代码问题来解决我的问题.
this code is not work
I want to take a format that apply on all the columns that contain a date. and when csv file load , date format automatically applied . not on index number. because I have no more Confident that all the values always at their particular cell position.
so please so my problem by solve this code problem
推荐答案
您如何将这些数据选择到csv文件中?
您可以使用
What do you do to select those data into the csv file?
You can use
dateTime.ToString("mm/dd/yyyy");
并将字符串值导出到您的CSV文件.
and export the string value to your CSV file.
这篇关于固定在datagridveiw或数据集中的日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!