datagridvew日期格式问题 [英] datagridvew date format issue

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

问题描述

我希望从datagridview中只有日期应该从到期日期列传递到数据库.但是随着date.time也将过去.并且在该列的数据库数据类型中是datatime.并且在形式上我正在转换列值转换为字符串格式........所以请帮我解决这个问题

I want that from my datagridview only the date should pass from expiry date column to the database.but with the date.time is also going.And in database data type of that column is datatime.and on form i am converting that column value to string format........so please help me out with this problem

推荐答案

.NET DateTime 结构同时存储Date和在 http://msdn.microsoft.com [ ^ ]
"DateTime值类型表示日期和时间,值的范围是0001年1月1日午夜12:00:00 Anno Domini"
同样,DataBase DateTime 类型也存储日期,时间.

它只是要在TextBoxDataGridView等中显示的格式,可以使用格式说明符之一显示Date,如此处所示

http://msdn.microsoft.com/en -us/library/system.globalization.datetimeformatinfo.shortdatepattern(v = vs.80).aspx [
The .NET DateTime structure stores both the Date and Time as given on http://msdn.microsoft.com[^]
"the DateTime value type represents dates and times with values ranging from 12:00:00 midnight, January 1, 0001 Anno Domini"
Similarly the DataBase DateTime type also stores both Date, Time.

It is only the format in which you want to display in TextBox, DataGridView, etc. for which you can use one of the format specifier to show the Date, as shown here

http://msdn.microsoft.com/en-us/library/system.globalization.datetimeformatinfo.shortdatepattern(v=vs.80).aspx[^]


DataGridView 没有DateTime 列.但是DateTimePicker 控件可以托管在DataGridView 单元中.这里给出一个例子

http://msdn.microsoft.com/en-us/library/7tas5c80.aspx [ ^ ]

在此示例中,在CalenderCell 的构造函数中,DataTimeFormat 设置为短日期格式.
The DataGridView does not have a DateTime column. But a DateTimePicker control can be hosted in DataGridView cell. An example is given here

http://msdn.microsoft.com/en-us/library/7tas5c80.aspx[^]

In this example in the constructor of CalenderCell the Format of DataTime is set to short date format.
public CalendarCell()
: base()
{
    // Use the short date format.
    this.Style.Format = "d";
}


这篇关于datagridvew日期格式问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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