When in AddItem mode, True DBList allows you to populate the list control (TDBList or TDBCombo) manually by using the AddItem, RemoveItem and Clear methods. In this mode, your application determines what data is contained within the list control.
To use AddItem mode, set the DataMode property of the control to 5 – AddItem at design-time, then use the AddItem method to populate the control.
The AddItem method allows you to populate individual rows within the list. The following code adds the names and street addresses to the list control.
Note: To display all data, you must add the necessary number of columns to your list control. For more information, see Adding and removing columns. |
Example Title |
Copy Code
|
---|---|
Private Sub Command1_Click() With TDBList1 .AddItem "Smith;John;210 Elm St." .AddItem "Doe;Jane;100 Oak St." End With End Sub |
Note: The default AddItem separator is “;”.You can choose a custom separator by setting the AddItemSeparator property at design-time or from code. |
The RemoveItem method allows you to remove rows from the list. The code below allows you to remove the selected row from the list control.
Example Title |
Copy Code
|
---|---|
Private Sub Command2_Click() TDBList1.RemoveItem TDBList1.SelectedItem End Sub |
The Clear method removes all items from the list population. The code below removes the entire population from the list control.
Example Title |
Copy Code
|
---|---|
Private Sub Command3_Click() TDBList1.Clear End Sub |