[Overview][Constants][Types][Classes][Procedures and functions][Index] | Reference for unit 'EditBtn' (#lcl)

# TDateEdit.ButtonClick

Displays a pop-up calendar dialog when the Button for the grouped edit control is clicked.

## Declaration

Source position: editbtn.pas line 624

`protected procedure TDateEdit.ButtonClick; override;`

## Description

ButtonClick is an overridden method in TDateEdit. It implements the virtual method defined in the ancestor class, and is called when the Button for the grouped edit control is clicked.

ButtonClick creates, displays, and executes a pop-up calendar dialog used to get a TDateTime value. The value in the Date property is passed as the initial date displayed on the dialog form. If Date contains the NullDate value, the current system date is used.

Values in the MinDate and MaxDate properties are used to validate and to limit the range of dates displayed on the pop-up calendar. When the properties contain non-zero values that are at least one day apart, they are used as the lower and upper limits for the value in Date. Otherwise, the MinDateTime and MaxDateTime RTL constants are used as the limits for the date value.

The ShowCalendarPopup routine is called to display and execute the dialog form. Set values in CalendarDisplaySettings and DefaultToday to control the appearance and behavior for the calendar on the dialog.

Remark:

For the Windows platform, additional validation is performed to ensure that Date is within the range of values allowed for the native calendar control. The minimum date value is "1752-09-14" (September 14, 1752) for the start of the Gregorian calendar. The maximum date value is "9999-12-31" (December 31, 9999). This is done to prevent an exception when an invalid value is passed to the native calendar control. When DefaultToday is enabled, Date defaults to the current system date for a value outside this range. When not enabled, the MinDate and MaxDate values are used to range limit the date.

Assign a routine to the OnAcceptDate event handler to perform actions needed when a new date value is selected using the dialog. Enable FocusOnButtonClick to focus and optionally auto-select the value in the edit control after the dialog has been closed.

## See also

TDateEdit.Date |  | Contains the TDateTime value for the control.
TDateEdit.MinDate |  | Smallest date value allowed in the date edit control.
TDateEdit.MaxDate |  | Largest date value allowed in the date edit control.
TDateEdit.CalendarDisplaySettings |  | Display or behavior options enabled in the pop-up calendar dialog for the control.
TDateEdit.DefaultToday |  | True to use the current system date when a Date value is not available.
TDateEdit.OnAcceptDate |  | Event handler signalled to accept or reject a new date value selected using the calendar dialog for the control.
TDateEdit.FocusOnButtonClick |  | Indicates if the focus is changed to the Edit control after the Button is clicked.
TDateEdit.EditDblClick |  | Performs actions needed when the Edit in the control is double clicked.
TCustomEditButton.ButtonClick |  | Performs actions needed when the button for the control is clicked.
TCustomEditButton.Button |  | TSpeedButton instance used on the edit control.
TCustomAbstractGroupedEdit.FocusAndMaybeSelectAll |  | Gives focus to the control, and optionally selects text in its editor.
ShowCalendarPopup |  | Creates, configures, and displays a TCalendarPopupForm instance.