If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Delphi, C etc > Delphi adotable > list all values as DBComboBox items?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-20-04, 09:26
doze doze is offline
Registered User
 
Join Date: Jul 2004
Posts: 19
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.

Please help the newbie
Reply With Quote
  #2 (permalink)  
Old 10-20-04, 21:16
doze doze is offline
Registered User
 
Join Date: Jul 2004
Posts: 19
Ok, I were thinking it all wrong.. did it like this:

Created these:

ADOConnection1
ADOQuery1
DataSource1
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:

ComboBox1.Clear;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('SELECT * FROM tablename');
ADOQuery1.Open;
while not ADOQuery1.eof do
begin
ComboBox1.items.add(ADOQuery1.FieldValues['column_of_the_item']);
ADOQuery1.next;
end;
ComboBox1.ItemIndex := 0;
ADOQuery1.First;

And at the ComboBox OnChange event I made this:

var CbBox_item: string;
begin
CbBox_item := ComboBox1.Text;
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Add('SELECT * FROM tablename WHERE column_of_the_item Like "'+CbBox_item+'"');
ADOQuery1.Open;
end;

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..
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On