datetime picker cntrol [英] datetime picker cntrol

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

问题描述

我使用以下代码在datetime选择器中设置null值。


dtInsuranceDate.Text = row [" DateInsured"]。ToString();我正在从数据库行中分配值


如果  dtInsuranceDate.Text = '01 -01-1900 '和 当我点击日期时间选择器以使用正确的日期更新值时, 我怎么能带来 当前日期 作为日历弹出窗口的默认值而不是
到01-01-1900。任何帮助将不胜感激

 

dtInsuranceDate.Text = row [" DateInsured"]。ToString();

if(dtInsuranceDate.Value.ToShortDateString()==" 01/01/1900")
{
dtInsuranceDate.Format = DateTimePickerFormat.Custom;
dtInsuranceDate.CustomFormat ="英寸;
checkBox3.Checked = true;

}

感谢


Pol





polachan

解决方案

嗨Pol,


>>如何在日历弹出窗口中将当前日期作为默认日期而不是01-01-1900。


您可以在if语句中设置当前日期:

 dtInsuranceDate.Text = row [" DateInsured"]。的ToString(); 
if(dtInsuranceDate.Value.ToShortDateString()==" 01/01/1900")
{
//dtInsuranceDate.Format = DateTimePickerFormat.Custom;
//dtInsuranceDate.CustomFormat ="英寸;
dtInsuranceDate.Format = DateTimePickerFormat.Long;
dtInsuranceDate.Value = DateTime.Now;
checkBox3.Checked = true;
}


注意:我注意到你问过一些问题,比如
此主题
,你现在解决了吗? ?如果是这样,请通过将有用的回复标记为答案来关闭主题,因为这将有助于其他人在路上寻找相同或类似的问题。



问候,



Stanly


I am using the following code to set the null value in datetime picker.

dtInsuranceDate.Text = row["DateInsured"].ToString(); I am assigning the value from database row

If dtInsuranceDate.Text ='01-01-1900' and and   when I click the datetime picker to update the value with correct date ,  how can I bring the  current date  as default in the calendar popup rather than going to 01-01-1900. Any help would be appreciated

dtInsuranceDate.Text = row["DateInsured"].ToString();

if (dtInsuranceDate.Value.ToShortDateString() == "01/01/1900") { dtInsuranceDate.Format = DateTimePickerFormat.Custom; dtInsuranceDate.CustomFormat = " "; checkBox3.Checked = true; }

With thanks

Pol


polachan

解决方案

Hi Pol,

>>how can I bring the current date as default in the calendar popup rather than going to 01-01-1900.

You can set the current date in the if statement:

    dtInsuranceDate.Text = row["DateInsured"].ToString();
    if (dtInsuranceDate.Value.ToShortDateString() == "01/01/1900")
    {
        //dtInsuranceDate.Format = DateTimePickerFormat.Custom;
        //dtInsuranceDate.CustomFormat = " ";
        dtInsuranceDate.Format = DateTimePickerFormat.Long;
        dtInsuranceDate.Value = DateTime.Now;
        checkBox3.Checked = true;
    }

Note: I noticed that you asked some questions like this thread, have you solved it now? If so, please close the thread by marking the helpful reply as answer as this will help others looking for the same or similar issue down the road.

Regards,

Stanly


这篇关于datetime picker cntrol的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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