How to set the current time in a DateTimePicker

You need to put that code after the InitializeComponent() call is made. There is no instance of myDateTimePicker until that point.


Declare your DateTimePicker and try it.

DateTimePicker myPicker = new DateTimePicker;
myPicker.Value = DateTime.Now;

Like someone pointed out, put your code before the InitializeComponent() since it's in that part that your DateTimePicker gets initialized.

1 - Delete you control
2 - Re-add it.
3 - Watch where you put your code.

Should work after that since your doing it right on the code part.