In many data tables, data is stored in code, such as in class coded data table tB03 (table 5. 5), the Department field TB0309 is stored in the encoding method, the real name of the department is stored in the Department Code table TB06. The advantage of using code is that the user can change the department name of the TB0602 field in the encoded table TB06 without affecting the run of other data tables (such as TB03) that use that encoding. The disadvantage is that when a user loses data encoding, it must query the meaning of the encoding, such as "OO" for "Basic", "1 O" "Mechanical System", which brings a lot of trouble to data entry. The best way is for the user to directly select the department name in the program interface, and the actual input is the department code. To this end, Delphi provides the DbLookup. Conbobox, Dbi,ookuplistbox Data interface components to help users solve the above problems.
The Dblookupconbobox component and the Dbcombobox component function Similarly, by selecting the data item in the drop-down list box to enter the value of the specified field for the current record. The difference is that the contents of the D Bconbobox component list box are entered by the programmer through the Items property, while the contents of the Dblookupconbobox component's list box are provided by the Database encoding table. Therefore, the Dblookupcombobox component does not have the Items property. When you use the Dblookupcombobox component to edit a data table field value, you must first place two dataset components (Table). A corresponding to the main table to input data (such as Class Code table TABLE_TB03), and the other corresponding to the data encoding from the table (such as the Department of Coding tables Table one TB06), and then put people 2 data source components: DATASOURCE_TB03, DATASOUROE_TB06, Follow the steps below to set its properties.
1. Important attributes
(1) DataSource Property
This property is used to connect the main table data source to which you want to edit data, such as Student class table data source datasource-tb03.
(2) DataField Property
This property is used to specify the name of the data field to be edited, such as the TB03 coded field TB0309 in the.
(3) The Listsource property.
This property is used to provide connection data encoded from a table data source, such as a department-encoded data source DATASOURCE-TB06.
(4) Keyfield Property
This property is used to specify the data encoded from the table's keywords, typically data-encoded fields, such as the Department data encoding field
TB060 1 O
(5) ListField Property
This property is used to select the name of the field in the data table to display in the list box, such as the department name TB0602.
With the settings of the above 5 properties, you can use the Dblookupcombobox component's drop-down list box to record the data you need.
(6) Dropdownalign Property
This property is used to set the arrangement of data items in a drop-down list box, with the following values: Daleft, Daright, Dacenter, left-aligned, right-aligned, and center-aligned.
(7) Dropdownrows Property
This property is used to set the drop-down list box to display the number of rows by default, such as setting 1 O rows and so on O
(8) DropDownWidth Property
This property is used to set the width of the drop-down list box. A value of O indicates a width equal to the edit box.
2. Common methods and events
(1) Closeup method
If the component is finished with a drop-down, the Oncloseup event is triggered when only the edit box is displayed and the drop-down list box is not displayed.
(2) Dropdown method
The Oncloseup event is triggered when a drop-down list box is displayed if the component is not finished by a drop-down