Hi All,

I have many DateTimePicker (DTP) in a windows form (Say atleast 15 DTP)
I need to do following things in the form

1)A Dataset is field with values from database (MS SQL) which contains the DateTime data and now i want to assign it to DTP and Doing as Follows
if (Ds.Tables[0].rows[0]["FieldDateTime"].Tostring()!=null)
Here in Else Condition DTP.text get the Todays by Default which i dont want to do this

2) I tried with doing
DTP.CustomFormat=" ";

The DTP Text Gets Blank , but again if i want to select(Modify) the DTP values again the DTP control does not select the required date.

Could you pls provide me the solution if any.

THank you

DateTimePicker can't be set to null because DateTime cannot be null.

One possible option is to create a custom DateTimePicker control which inherits from the stock DateTimePicker control. The Format and CustomFormatProperties cannot be used from the stock DatetimePicker control. Thus, you'll have to create new properties which will be implemented in you new inherited control. Using your new modified, inherited control will now allow you to set DPT to null.

Hey dude
You must know the restrictions in DPT.DPT will not allow null value.

For Programming Purpose note:if you need then only you can assign the date like

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.