Unanswered: Delphi adotable > list all values as DBComboBox items?
how I can get the dbcombobox to list all values from an adotable column..?
I have set up an adoconnection, adotable and datasource to the dbcombobox and it shows the first record on the combobox by default.
When I change to another record from the grid, it changes the text to that record on the dbcombobox, but the list of the dbcombobox is empty.. do I have to set the items property to something?
What I'm trying to do is that users could see all usernames in the dbcombobox from users table, and when user selects an username from the dbcombobox, it would display all info on that user at the dbedit boxes below.
Ok, I were thinking it all wrong.. did it like this:
ComboBox1 (which value controls the other components)
and all other components as dbcomponents (dbedit/dbcheckboxes and such)
Set all of the dbcomponents to use adoquery1
On the form OnShow event I made this:
ADOQuery1.SQL.Add('SELECT * FROM tablename');
while not ADOQuery1.eof do
ComboBox1.ItemIndex := 0;
And at the ComboBox OnChange event I made this:
var CbBox_item: string;
CbBox_item := ComboBox1.Text;
ADOQuery1.SQL.Add('SELECT * FROM tablename WHERE column_of_the_item Like "'+CbBox_item+'"');
Works great when I got the hang of it how it could be done.. Is there something bad about the way I did it? It works great, but if there's some better/right way to do this, please tell..