固定在datagridveiw或数据集中的日期格式 [英] Date format fixed in datagridveiw or dataset

查看:74
本文介绍了固定在datagridveiw或数据集中的日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

开发者
我的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屋!

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