Contains extended database controls.

dbextctrls.pp contains extended database-aware controls used in the Lazarus Component Library (LCL).

The following components are added to the Lazarus IDE component palette:

Data Controls Tab

  • TDBDateEdit

It also registers TFieldClass instances (defined in DefaultFieldClasses) associated with FCL database field types, and includes TIntegerField as an alias for TLongintField.

TDBDateEdit implements a data-aware editing control for a date field in a dataset.

TDBDateEdit is a TDateEdit descendant that implements a data-aware edit control for a Date field in a dataset. Like its ancestor class, TDBDateEdit includes a Button which opens a Date selection dialog (calendar).

TDBDateEdit extends the ancestor class to provide support for TFieldDataLink, TDataSource, and TField which provide access to the dataset with the data for the editing control. Overridden methods are provided which handle keystrokes and synchronize changes in the control with the field in a dataset. Support for TBasicAction is also included in TDBDateEdit.

TDateEdit TFieldDataLink TField TDatasource TBasicAction
Gets the value for the control when its Field has changed.

DataChange is a procedure used to get the value for the control when the value in its Field has changed. DataLink must contain a value (not Nil) to access the Field. When DataLink is unassigned, the value in Text is set to an empty string ('').

DataChange stores the value from the TField instance in DataLink in the Date property. If the control is Focused and AutoSelect is enabled, the SelectAll method is called to select the content in the control.

DataChange is assigned as the OnDataChange event handler for DataLink in Create.

TFieldDataLink.Field TFieldDataLink.OnDataChange
Class signalling the data change. Updates the field in a dataset when the value for the control has changed.

UpdateData is a procedure which updates the field in a dataset when the value for the control has been changed. UpdateData uses the value in Text to determine if the control has no value. When Text contains an empty string (''), the Field in DataLink calls its Clear method. Otherwise, the value in Date is stored in the Field for the DataLink.

UpdateData is assigned as the OnUpdateData event handler for DataLink in Create.

TFieldDataLink.Field TFieldDataLink.OnUpdateData
Class signalling the update. Gets the value for the DataField property.

GetDataField is a String function used to get the value for the DataField property. GetDataField is the read access specifier for the property value. The return value is retrieved from the FieldName property in DataLink.

Use DataField to read or write the name of the field used to store the Date value in the dataset.

Value for the DataField property. Gets the value for the DataSource property.

GetDataSource is a TDataSource function used to get the value for the DataSource property. GetDataSource is the read access specifier for the property value. The return value contains the DataSource assigned in the DataLink property.

Use DataSource to read or write the value in the property.

TFieldDataLink TDatasource
Value for the DataSource property. Sets the value for the DataField property.

SetDataField is a procedure used to set the value in the DataField property. SetDataField is the write access specifier for the property value. SetDataField stores the specified new Value in the FieldName property for DataLink.

Use DataField to read or write the value for the property.

Value for the DataField property. Sets the value for the DataSource property.

SetDataSource is a procedure used to set the value for the DataSource property. SetDataSource is the write access specifier for the property value. SetDataSource calls ChangeDataSource to store the specified new Value in DataLink.

Use DataSource to read or write the value in the property.

TFieldDataLink TDatasource
Value for the DataSource property. Responds to the CM_GETDATALINK control message.

CMGetDataLink is a procedure which responds to the CM_GETDATALINK control message. CMGetDataLink ensures that Message is updated to contain a pointer to the DataLink instance in its result.

Message for the control notification. Gets the value for the Field property.

GetField is a TField function used to get the value for the Field property. GetField is the read access specifier for the property value. GetField uses the value in the Field property in DataLink as the return value for the method.

Use Field to read the value in the property.

Value for the Field property. Handles notifications when a component is added or removed.

Notification is an overridden procedure used to handle notifications performed when aComponent is added or removed. Notification calls the inherited method. When Operation contains opRemove, and AComponent is the DataSource for the control, the value in DataSource is set to Nil.

Component for the notification event. Operation for the notification event. Indicates if the control can modify its contents.

EditCanModify is an overridden Boolean function which indicates if the control can modify the content for the control. EditCanModify is set to the value from CanModify in DataLink. The return value is True when the control accept new values.

True when the control value can be changed. Performs actions required when the Enter key is pressed on the control.

EditEnter is an overridden procedure used to perform actions required when the Enter key is pressed on the control. EditEnter calls the inherited method.

EditEnter uses the value from Editing in DataLink to determine if there are any pending changes in the control value. When Editing contains False, the Reset method in DataLink is called to cancel changes to the field. Reset also calls the OnDataChange event handler.

Handles special keys in the keydown state.

EditKeyDown is an overridden procedure used to perform actions required when special keys are in the down state in the control. EditKeyDown handles the following virtual key values:

VK_ESCAPE
Cancels editing (when active) and calls Reset in DataLink. Key is changed to the value VK_UNKNOWN
VK_DELETE or VK_BACK
Removes Delete and Backspace keys if editing is not active.Changes Key to the value VK_UNKNOWN when editing is not active.
Numeric value for the key. Shift state for the key. Ensures character values are valid for the control.

EditKeyPress is an overridden procedure which processes the character value in Key. EditKeyPress calls the inherited method. EditKeyPress checks the value in Key to see if it contains data (as opposed to control characters) in the range Decimal 32 to Decimal 255. The Field property in DataLink also calls its IsValidChar method to see if Key is valid for the data type in the Field.

EditKeyPress requires DataLink to have both a valid TField instance in its Field property and its Edit property set to True. The value in Key is set to #0 (Decimal 0) if either condition is not met.

Character value for the key. Actions performed when the button for the control is clicked.

ButtonClick is an overridden procedure which performs actions when the button for the control is clicked. ButtonClick ensures that the control is Focused, and calls SetFocus when necessary. The CanModify property in DataLink is checked to see if the Edit method in DataLink is needed. ButtonClick calls the inherited method.

Signals the control changed state.

EditChange is an overridden procedure which which signals the control is changed. EditChange ensures that the control updates its DataLink to indicate the change status. EditChange uses the Editing property in DataLink to see if the Modified method in DataLink is needed. EditChange calls the inherited method.

TFieldDataLink TFieldDataLink.Editing TFieldDataLink.Modified
Performs actions needed when the exiting the control.

EditExit is an overridden procedure performs actions needed when the exiting the control. EditExit calls the inherited method. EditExit ensures that the value in the control is applied to DataLink. When Editing is set in DataLink, its UpdateRecord method is called to apply the new value. If Editing is not set, its Reset method is called restore its value and state.

TFieldDataLink TFieldDataLink.Editing TFieldDataLink.Reset
Restores the control to its value in the dataset.

Reset is a procedure used to restore the control to its value in the dataset. Reset calls the Reset method in DataLink to get the value stored in its Field and to clear the Editing flag. Reset calls the inherited method prior to exit.

TFieldDataLink TFieldDataLink.Editing TFieldDataLink.Reset
Constructor for the object instance.

Create is the overridden constructor for the object instance. Create call the inherited constructor using AOwner as the owner for the object instance. Create allocates resources needed for the DataLink property, and sets the event handlers for its OnDataChange and OnUpdateData properties to the DataChange and UpdateData methods in the class instance.

TFieldDataLink TFieldDataLink.OnDataChange TFieldDataLink.OnUpdateData
Owner of the object instance. Frees the object instance.

Destroy is the overridden destructor for the object instance. Destroy frees resources allocated for the DataLink property, and calls the inherited Destroy method.

Perform the default action for the control.

ExecuteAction is an overridden Boolean function which implements support for using TBasicAction to perform the default action for the control. ExecuteAction calls the inherited method using the value in AAction. If the action is not handled in the ancestor, DataLink is used (when assigned) to performs its ExecuteAction method with the specified action value. The return value is True if the action is handled by the ancestor or DataLink.

TBasicAction TApplication.OnActionExecute
True if the action is successfully handled. Action to perform. Updates the action when it handles the specified operation.

UpdateAction is an overridden Boolean function which implements support for using TBasicAction to update the value in the control from its dataset. UpdateAction calls the inherited method using the value in AAction. If the action is not handled in the ancestor, DataLink is used (when assigned) to perform its UpdateAction method with the specified action value. The return value is True if the action is handled by the ancestor or DataLink.

TBasicAction
True if the action is successfully handled. Action to perform. TField class which reads and writes data for the control.

Field is a read-only TField property which reads and writes data for the control in its dataset. Field is a convenience method which returns the TField instance from the DataLink for the control. GetField is the read access specifier for the property.

The value in Field cannot be assigned directly; use DataField to specify the field name for the editing control. Use DataSource to set the dataset used for data in the control.

TFieldDataLink TField
Name of the field in the dataset.

DataField is a String property that provides the name of the field used to store the Date value in its Dataset. GetDataField is the read access specifier for the property value. SetDataField is the write access specifier for the property value. These methods read and write the value in FieldName for the DataLink.

Use DataSource and DataField to provide the dataset and field name for the control.

TFieldDataLink
Provides access to the dataset used for the editing control.

DataSource is a TDataSource property which provides access to the dataset used for the editing control. GetDataSource is the read access specifier for the property, and uses the DataSource in DataLink as the property value. SetDataSource is the write access specifier for the property, and sets the DataSource in DataLink to the specified value.

TFieldDataLink TDatasource
Registers components for use in the Lazarus IDE.

The following components are added to the Lazarus IDE component palette:

Data Controls Tab

  • TDBDateEdit