Reputation: 511
I have a winform that contains two datetime picker one name start time and second is end time, now when i run my winform the value displayed in both the date time picker are same i.e current date time. But i wanted it to be like that my end time datetime picker shows current date time and start time datetime picker shows 24 hrs previous time.
Tell me how to do that, i have set the format property of datetime picker to custom.
Upvotes: 0
Views: 114
Reputation: 222
You can change the selected date by setting the Value
property.
There is an example in the official docs.
Upvotes: 1
Reputation: 81493
Just set the appropriate fields on form load, or in the constructor after initalization
dateTimePicker1.Value = DateTime.Now;
dateTimePicker2.Value = DateTime.Now.Days(-1);
Gets or sets the date/time value assigned to the control.
Upvotes: 3