Tuesday, March 4, 2014

TCalendarDialog tutorial

For this tutorial we need:
4 labels(Standard Tab) ,
2 buttons (Standard Tab),
1 calendardialog(Dialogs Tab),
1 edit(Standard Tab),
1 statictext(Additional Tab).


The top button opens a calendar that let us choose a date.





When we press ok button in the main form,  we can see the result in green label.

Here is the code for ok button

procedure TForm1.Button2Click(Sender: TObject);
begin
  label4.Caption:='Your name is '+edit1.Text+' and your birthday is '+statictext1.Caption;
end;    




And the code for calendar button

procedure tForm1.Button1Click(Sender: TObject);
begin
  if calendardialog1.Execute then
     statictext1.Caption:=datetostr(calendardialog1.Date);
end;


We use datetostr function to convert our date to string.

Thats all for now...

1 comment:

  1. Thank you for making this tutorial. This really helped me. The calendar is different in Lazarus compared to Gambas, and now it makes sense to me.

    ReplyDelete