Tutorials > Tutorial 2 - Incremental Search and Auto Completion with True DBCombo |
This tutorial demonstrates the incremental search facility of the True DBCombo control. When the control receives focus, any keys the user types are concatenated into a search argument, and the list portion of the control instantly highlights the next matching entry, if found. You can also enable the AutoCompletion property to cause the remainder of the matching entry to be appended to the combo's text box.
Start a new project.
Place a Data control (Data1) and a True DBCombo control (TDBCombo1) on the form (Form1) as shown in the following figure.
Set the DatabaseName (Data control) property of Data1 to TDBLDemo.mdb, and the RecordSource (Data control) property to Composer.
Set the RowSource property of TDBCombo1 to Data1, the ListField property to Last and the MaxComboItems property to 8.
Run the program and observe the following:
The True DBCombo control retrieves the database schema information from the Data control and automatically configures itself to display all of the fields contained in the database table. Note that the field displayed in the text box portion is the one specified by the ListField property.
Click the combo's drop-down button or press Alt + Down Arrow to open the list portion of TDBCombo1.The last name of the first composer in the table remains selected in the text box portion. Type the letter b.Note that the b replaces the selected text, and the current row in the list portion moves to the first last name that begins with b: in this case Bach.Type e and the list will reposition to Beethoven, type r and the list will jump to Berg. At this point, if you press the Enter key or click the highlighted row, the list portion of the combo will close and a complete last name (Berg) will appear in the text box. This value is also used to fill the BoundText property, as described in the next tutorial.
Press the End button on the Visual Basic toolbar to end the program. In design mode, select TDBCombo1 and in the Visual Basic Properties window change the AutoCompletion property to True.
Run the program again and observe the following:
Open the list portion of TDBCombo1 as described earlier. Note that with each letter you type, TDBCombo1 now fills in the text box with the rest of the matching last name, if any.Also, the part that was filled in is selected. For example, if you type be, the letters ethoven will be added and selected. Experiment by pressing the Del and Backspace keys.
To end the program, press the End button on the Visual Basic toolbar. You have successfully completed Tutorial 2.