The DBEdit Component

DBEdit is the basic building block of any type of data entry application This component is limited to a single line of text and both displays and opens the dataset field to modification. DBEdit offers some degree of control over the formatting of the data being input and displayed using a number of property settings. Similar to the previous component, DBEdit is a data-aware version of the TEdit class. Review the data type that needs to be supported to determine if this is the appropriate control to be used or if the data can be better represented using a DBMemo control.

Key Properties

The properties to be discussed in the context of the DBEdit control are focused mainly on the formatting of the data for input or display purposes.


To aid the user in quickly replacing the text displayed in a DBEdit control, the AutoSelect property can be set to automatically select all text when the control receives focus. If the property is set to the default value of True, all of the text is automatically selected when the user clicks on the field or tabs into the field. The contents of the field are then replaced as soon as the first editing keystrokes are received by the control. When the property is False, the user must double-click on the text in order to select it.


The AutoSize property for the DBEdit component differs slightly from similarly named properties seen previously. When the property is True, the height of the control can resize automatically to accommodate changes in the text size. The changes can be driven by items such as th e font or border style of the control. When the value of the property is False, the height is fixed and changes in conditions are ignored.


The case of the text in the DBEdit component can be controlled through the CharCase property. The default value of ecNormal accepts and displays the text input as the user provides it. When the property is set to ecUpperCase or ecLowerCase, text that is input is automatically converted to the appropriate case and permanently modified. The text

Chapter 6-Delphi's Data-Aware Components u is stored in the dataset field as it is formatted by CharCase and cannot be reversed by selecting the opposite or normal case.


MaxLength determines the maximum number of characters that can be entered into this control when no EditMask is in use.


The PasswordChar property is unique to the DBEdit component. It replaces the actual characters typed with the character specified in this property, an asterisk for example. When the user types into the field, the string is hidden behind the string of asterisks, making it ideal for use in gathering password information or other data that must be guarded.

Was this article helpful?

0 0

Post a comment