It looks like DateTimePicker
raises ValueChanged
twice:
- once with
MaxDate
- once with current
Value
on DropDown opened, if Value
is not the MaxDate
.
To reproduce drop DateTimePicker
to the form, put
dateTimePicker1.MinDate = new DateTime(2024, 5, 31);
dateTimePicker1.MaxDate = new DateTime(2024, 6, 2);
dateTimePicker1.Value = dateTimePicker1.MaxDate.AddHours(-1);
to the Load
event handler.
Wire up ValueChanged
event and add some debug output:
private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
System.Diagnostics.Debug.WriteLine(DateTime.Now.ToString("mm:ss:ms") + " :: " + dateTimePicker1.Value.ToShortDateString() + " __ " + dateTimePicker1.Value.ToShortTimeString());
}
Each time the DropDown being opened the event ValueChanged
fired twice (except Value
is MaxDate
, in this case no ValueChanged
being raised as expected).
Is there any setting, which triggers this odd behavior, or is it a “by design” bug?