Board index » delphi » Selections from a combobox using IBSQL

Selections from a combobox using IBSQL

I am trying to let the user select an Id from a list of users. The user IDs
are stored as varchar(3) and they have a name associated with them.
I would like to select the name but store the ID. The only way I have got
around this is to have another Tstrings object as a private member of the
form to store the IDs and then use the onChange event of the combobox. I'm
not sure if this is the best practice or is there a better way.

The reason I don't want to use the TDBLookupCombo is that I do some
processing on which users can be selected in different comboboxes. At the
moment all the combos are filled in the form.Create method using one SQL.

 

Re:Selections from a combobox using IBSQL


Quote
In article <[email protected]>, [email protected] wrote...

Hi,

Quote
> I am trying to let the user select an Id from a list of users. The user IDs
> are stored as varchar(3) and they have a name associated with them.
> I would like to select the name but store the ID. The only way I have got
> around this is to have another Tstrings object as a private member of the
> form to store the IDs and then use the onChange event of the combobox. I'm
> not sure if this is the best practice or is there a better way.

Have you thought about using the Combo.Items.Objects for this?  I do
this sort of thing all the time with integer ID's  e.g.

combo.items.addobject(NameField.Value, TObject(IDField.Value));

....

IDField.Value := Integer(combo.items.objects[2])

Dave

Other Threads