The problem lies in the fact that the OnChange fires when the month or
year is changed in the ppopup as well. I know I can use the OnClosup but
that wouldn't handle keyboard input.
How could I do this and still handle both keyboard input as well as the
drop down calendar but not show the error message when month/year are
changed in the dropdown calendar?
Try something like this:
procedure TForm1.DateTimePicker1DropDown(Sender: TObject);
begin
DateTimePicker1.OnChange:=nil;
end;
procedure TForm1.DateTimePicker1CloseUp(Sender: TObject);
begin
DateTimePicker1.OnChange:=DateTimePicker1Change;
DateTimePicker1Change(nil);
end;
procedure TForm1.DateTimePicker1Change(Sender: TObject);
begin
if DateTimePicker1.Date<DateTimePicker2.Date
then DateTimePicker1.Date:=DateTimePicker2.Date;
end;
Vlastik