S
sherifffruitfly
Hi all,
The following function is the ValueChanged handler for two
DateTimePicker thingies - allowing the user to specify a date range. I
don't understand why the following bug exists: when the first picker is
set later than the second, the messagebox pops up *twice* in
succession.
What's causing that? How can I achieve the (obvious) desired effect?
Thanks for any thoughts,
cdj
================
private void checkDates(ref DateTimePicker first, DateTimePicker
second)
{
if (first.Value.Date > second.Value.Date)
{
MessageBox.Show("End date may not be earlier than start date.",
"Rates Aggregator");
//I would MUCH rather not allow the change to be made at all,
//but this will do for now.
first.Value = second.Value;
}
}
private void dateTimePickerStart_ValueChanged(object sender,
System.EventArgs e)
{
checkDates(ref dateTimePickerStart, dateTimePickerEnd);
}
The following function is the ValueChanged handler for two
DateTimePicker thingies - allowing the user to specify a date range. I
don't understand why the following bug exists: when the first picker is
set later than the second, the messagebox pops up *twice* in
succession.
What's causing that? How can I achieve the (obvious) desired effect?
Thanks for any thoughts,
cdj
================
private void checkDates(ref DateTimePicker first, DateTimePicker
second)
{
if (first.Value.Date > second.Value.Date)
{
MessageBox.Show("End date may not be earlier than start date.",
"Rates Aggregator");
//I would MUCH rather not allow the change to be made at all,
//but this will do for now.
first.Value = second.Value;
}
}
private void dateTimePickerStart_ValueChanged(object sender,
System.EventArgs e)
{
checkDates(ref dateTimePickerStart, dateTimePickerEnd);
}