Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DateTimePicker - OnChange/OnCloseUp

701 views
Skip to first unread message

eshipman

unread,
Feb 28, 2005, 3:20:41 PM2/28/05
to
I have two datetimepickers. One for a min date, one for a max date.
I also have the checkboxes enabled.
I have an OnChange handler that they are both set to. If I change the
max date, I want to make sure that it is not < the min date if the
mindate is checked. If it is, I show an error message and focs the
max date picker.

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?

greybeard

unread,
Feb 28, 2005, 9:28:29 PM2/28/05
to
> 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.

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


eshipman

unread,
Mar 1, 2005, 12:07:22 PM3/1/05
to
In article <4223d358$1...@newsgroups.borland.com>, vlastik...@senior.cz
says...
Don't know why I didn't think of that but it works, thanks...
0 new messages