开发者

How Can I Make the value of a date time picker value to null when loading a form?

How Can I Make the value of a date time picker value to null when loading a form? When I am using datetimepicker, it is displaying a default value when the form is loading. I have set both the minimum and maximum date for datetimepicker.

My Requirement is "to display null value(Nothing) in the datetimepicker so that user have to select date from the datetimepicker". I refereed so many sites. All those about Custom formats. I have my o开发者_如何学JAVAwn idea. i,e Taking a button as Readonly and in the button click event, i can make the datetimepicker as visible. // in the datetimepicker_DateSelectd Event Button.text=datetimepicker.value;

But i dint satisfy with this. Can u please suggest me.


One thing you could do is

dtpConstDate.CustomFormat = " "; 
dtpConstDate.Format = DateTimePickerFormat.Custom;

On value change you could do

private void dtp_ValueChanged(Object sender, EventArgs e) {

  dtp.Format = DateTimePickerFormat.Short; 

}

So the idea is simple you could change the datetime picker format accordingly to achieve your goal.


Have you tried setting the Text property?

dateTimePicker.Text = string.Empty; 

or if in WPF:

<DateTimePicker Text="" />


You can do that as following ....

1 : Set Date Formate to be "CUSTOM" 2 : Then CustomFormate = " " (Single Space)

When you did that you will see your datetimepicker blank ........... but when you will run your program and try to select any date, you will not be able see your selected date ....... It will be still blank.

Solve it as following ............

Date1.CustomFormat = "dd/MM/yyyy"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜