Board index » delphi » Populating a combo box

Populating a combo box

My problem is, how do I fill combo box from a query.

The query has a number and a name field.
In the como box I wish to display only the name field.
The number is not visible, but is used as a reference when the user selects
an item from the combo box.

With this reference I wish to populate the second combo box eg. orders for
the selected name.

Last question, is it also possible to add icons to the como box for each
item and is it best to write all of the above in code.

Thanks in advance for any help anyone can give.

Mark

 

Re:Populating a combo box


Below is some code that will enable you to populate a combo box with every
name from the name field.

with query1 do begin
  First;
  while not eof do begin
    Combobox1.Items.Add(FieldByName('Name').AsString);
    Next;
  end;
end;

I hope this helps

Benny (dickie_...@hotmail.com)

Quote
John Mark Barber wrote in message <7mhgeb$2...@forums.borland.com>...
>My problem is, how do I fill combo box from a query.

>The query has a number and a name field.
>In the como box I wish to display only the name field.
>The number is not visible, but is used as a reference when the user selects
>an item from the combo box.

Other Threads