Part 6 – Adding a list view

Now we will utilize the power of control binding to create a list view for our database. Add a window to your project and call it “listWindow”. Add a listbox to the window and give it 4 columns as shown below. Also add a DatabaseQuery control to the window.


databasequeryproaIn the Properties window for DatabaseQuery1 enter the values shown here.

Notice the SQLQuery is the same as for the DataControl on the Data Browser window.

To bind Listbox1 and DatabaseQuery1 to each other hold down the Command and Shift keys and drag from the DatabaseQuery control to anywhere in the Listbox. When you release the mousebutton a dialog like the one below will appear. Select the first option in the list.


Finally, put this code in the window’s Open event:


Now when the window opens DatabaseQuery1 will run its query and retrieve all of the records from the “People” table. The binding between DatabaseQuery1 and Listbox1 will take care of listing the records in Listbox1.

The record fields (columns) will be displayed in alphabetical order from left to right.


Xojo wizardry has saved us from having to enter any complicated code in order to present this list view of our database. Without this magic we would have had to get much more heavily into SQL. Thank you Xojo!

Download this project