You need to write an OnChange
event OnChange
to select a date. You also need to make sure that this event handler fires when the form shows:
procedure TForm1.UpdateDateTimeLabel; var SelectedDate, SpecialDate: TDateTime; begin SelectedDate := DateTimePicker1.DateTime; SpecialDate := EncodeDate(2012, 2, 16); if IsSameDay(SelectedDate, SpecialDate) then Label1.Caption := 'Hello World' else Label1.Caption := ''; end; procedure TForm1.DateTimePicker1Change(Sender: TObject); begin UpdateDateTimeLabel; end; procedure TForm1.FormShow(Sender: TObject); begin UpdateDateTimeLabel; end;
source share