Sign in Join
Wiki copytemporary

DateControls Package for Lazarus: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11> **Note:** These controls are now obsolete. The controls in [[DateTimeCtrls Package]] have improved functionality and completely cover the functionality of these!
22
33## Author
44
55
66Zoran Vučenović
77
88## Introduction
99
1010DateControls package contains two controls:
1111
1212![](/wiki-images/1/18/TDatePicker.PNG) TDatePicker and ![](/wiki-images/e/e8/TDBDatePicker.PNG)TDBDatePicker
1313
1414**These controls are now obsolete. The controls in [[DateTimeCtrls Package]] have improved functionality and completely cover the functionality of these!**
1515
1616Delphi's VCL has a control named [TDateTimePicker](http://docwiki.embarcadero.com/VCL/en/ComCtrls.TDateTimePicker), which I find very useful for editing dates. LCL, however, does not have this control. Instead, for editing dates LCL has a control named [TDateEdit](http://lazarus-ccr.sourceforge.net/docs/lcl/editbtn/tdateedit.html), but I prefer the VCL's TDateTimePicker.
1717
1818Therefore, I tried to create a cross-platform Lazarus control which would resemble VCL's TDateTimePicker as much as possible.
1919
2020The TDatePicker control does not use [native Win control](http://msdn.microsoft.com/en-us/library/system.windows.forms.datetimepicker.aspx). It descends from LCL-s TCustomControl to be cross-platform. It has been written and initially tested on Windows XP with Win widgetset, but then tested on Ubuntu Linux 9.10 with gtk2 widgetset, where additional adjustments had been made.
2121
2222Thanks to Željko Rikalo, its tested on qt and adjusted to be fully functional to qt users.
2323
2424Note that the TDatePicker control does not descend from TEdit, so it does not have unnecessary caret. The VCL's control doesn't have caret either.
2525
2626Unlike VCL's control, this control has no time editing feature. It can be used for date editing only. That's why it is named TDatePicker, not TDateTimePicker.
2727
2828## Downloading and installing
2929
3030Lazarus package DateControls.lpk can be downloaded [from here](http://datepicker.000space.com), packed in zip format.
3131
3232After downloaded, unzip the package.
3333
3434To install the package in Lazarus IDE follow these steps:
3535
36361. Open the package in Package Editor (in Lazarus' main menu click *Package*, then *Open package file...* locate the file *datecontrols.lpk* and click *Open*).
37372. Compile the package (click *Compile* in Package Editor's tool bar).
38383. Install the package in the IDE (click *Install* – you will be asked if you want to rebuild Lazarus, click *Yes*. Wait until Lazarus rebuilds and restarts itself. The new tab *DateControls* appears on the component palette with TDatePicker and TDBDatePicker controls.
3939
4040## TDatePicker ![](/wiki-images/1/18/TDatePicker.PNG)
4141
4242### properties
4343
4444I'll explain some properties of TDatePicker control:
4545
4646#### TheDate: TDateTime
4747
4848
4949The date displayed on the control. This property is named TheDate, not Date, to avoid name conflict with [Date function](http://lazarus-ccr.sourceforge.net/docs/rtl/sysutils/date.html).
5050
5151#### MinDate: TDateTime
5252
5353
5454The minimal date user can enter.
5555
5656#### MaxDate: TDateTime
5757
5858
5959The maximal date user can enter.
6060
6161#### NullInputAllowed: Boolean
6262
6363
6464When True, the user can set the date to NullDate constant by pressing N key.
6565
6666#### CenturyFrom: Word
6767
6868
6969When user enters the year in two-digit format, then the CenturyFrom property is used to determine which century the year belongs to. The default is 1941, which means that when two digit years is entered, it falls in interval 1941 – 2040. Note that MinDate and MaxDate properties can also have influence on the decision – for example, if the CenturyFrom is set to 1941 and MaxDate to 31. 12. 2010, if user enters year 23, it will be set to 1923, because it can’t be 2033, due to MaxDate limit.
7070
7171#### ShowCalendar: Boolean
7272
7373
7474When set to True, there is a button on the right side of the control. When user clicks the button, [the calendar control](http://lazarus-ccr.sourceforge.net/docs/lcl/calendar/tcalendar.html) is shown, allowing the user to pick the date.
7575
76-<figure>
77-<img src="ShowCalendar.PNG" title="ShowCalendar.PNG" />
78-<figcaption>ShowCalendar.PNG</figcaption>
79-</figure>
76+![](/wiki-images/2/27/ShowCalendar.PNG)
8077
8178#### ShowCheckBox: Boolean
8279
8380
8481When set, there is a check box on the left side of the control. When unchecked, the display appears grayed and user interaction with the date is not possible. (The control is still enabled, though, only in sense that the check box remains enabled).
8582
86-<figure>
87-<img src="ShowCheckBox.PNG" title="ShowCheckBox.PNG" />
88-<figcaption>ShowCheckBox.PNG</figcaption>
89-</figure>
83+![](/wiki-images/6/63/ShowCheckBox.PNG)
9084
9185#### Checked: Boolean
9286
9387
9488If ShowCheckBox is set to True, this property determines whether the check box is checked or not. If ShowCheckBox is False, this property has no purpose and is automatically set to True.
9589
9690#### DateDisplayOrder: TDateDisplayOrder
9791
9892
9993**type** TDateDisplayOrder = (ddoDMY, ddoMDY, ddoYMD, ddoTryDefault);
10094
10195
10296Defines the order for displaying day, month and year part of the date. When ddoTryDefault is set, then the controls tries to determine the order from [ShortDateFormat global variable](http://lazarus-ccr.sourceforge.net/docs/rtl/sysutils/shortdateformat.html).
10397
10498This is similar to DateEdit's [DateOrder](http://lazarus-ccr.sourceforge.net/docs/lcl/editbtn/tdateedit.dateorder.html) property.
10599
106100#### TheDateSeparator: UTF8String
107101
108102
109103Defines the string used to separate date, month and year date parts. Setting this property automatically sets the UseDefaultDateSeparator property to False. This property is named TheDateSeparator, not DateSeparator, to avoid name conflict with [DateSeparator global variable](http://lazarus-ccr.sourceforge.net/docs/rtl/sysutils/dateseparator.html).
110104
111105#### UseDefaultDateSeparator: Boolean
112106
113107
114108When UseDefaultDateSeparator is set to True, TheDateSeparator property is set to [DateSeparator global variable](http://lazarus-ccr.sourceforge.net/docs/rtl/sysutils/dateseparator.html).
115109
116110#### TrailingSeparator: Boolean
117111
118112
119113When set to True, then TheDateSeparator is shown once more, after the last date part. This property exists because in some languages the correct format is 31. 1. 2010. including the last point, after the year.
120114
121115#### LeadingZeros: Boolean
122116
123117
124118Determines whether the date parts are displayed with or without leading zeros.
125119
126120#### TextForNullDate: UTF8String
127121
128122
129123Text which appears when the null date is set and control does not have focus. When control is focused, the text changes to defined format, but displaying zeros, which is appropriate to user input. User can set the date to NullDate by pressing N key, provided NullInputAllowed property is True.
130124
131125## TDBDatePicker ![](/wiki-images/1/18/TDatePicker.PNG)
132126
133127
134128TDBDatePicker is a data-aware version of TDatePicker, with nice way of handling null database values.
135129
136130### Handling of null values
137131
138132#### Displaying null values
139133
140134
141135When the underlying DB field has null value, then:
142136
143137
144138
145139If the control is not focused, then it displays the text defined in TextForNullDate property. The default is "NULL".
146140
147141
148142
149143When the control gets focus, the text changes to defined format, but displaying zeros (for example "00/00/0000"), which is appropriate to user input.
150144
151145#### Setting the field value to null
152146
153147
154148
155149If NullInputAllowed property is True, the user can set the date to null, by pressing N key.
156150
157151## See also
158152
159153- [[DateTimeCtrls Package]] Please use this package instead as DateControls is obsolete.
160154
161155---
162156*From the Free Pascal wiki, page "DateControls Package for Lazarus", as it stood on 2020-08-08 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
163157Category: Components
164158Category: Lazarus

Back to history