ComboBox that shows "Name" and returns "Value"? 
Author Message
 ComboBox that shows "Name" and returns "Value"?

 go> What I need to do is show the user a ComboBox that contains friendly
 go> names for database fields.  When he selects one, I need to retrieve
 go> the actual database name.  So I want to fill the ComboBox.Items with
 go> strings like 'Customer Name=CNAME'.  I want the box to only show the
 go> user 'Customer Name'.  Then my code can retrieve the actual field name
 go> 'CNAME'.

Look for Objects property, and AddObject method for TlistBox. You can
use any record type as attached object for each item in a listbox.
When user selects Item, take its index, and see record value attached
as object to that Item.

 go> Now, obviously, I could maintain two separate lists, and use the
 go> ComboBox.ItemIndex to look up the field name in a separate list.  But
 go> I want to keep the values together so that a later programmer cannot
 go> accidentally change one and not the other.

There is no need for that approach. First time I needed similar thing,
I did use two separate lists. Hopefully maintenance of those lists was
easy so I had no problems, except I had to take care to keep both lists
in sync.

When I realized what Objects property is for, I solved a problem. You
may do whatewer you want with items: sort, exchange, add, insert or
delete, attached objects stays in sync with items they are attached

Wed, 18 Jun 1902 08:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. The keys "-"/"+"/"*"

2. ""256 Color Mouse""

3. changing values to "no value"

4. MySQL-Problem with "SHOW CREATE TABLE"

5. "Show Databases" of MySQL server

6. "Like" returns read-only dataset

7. SQL: LIKE "%..." returns read-only dataset

8. "Name Not Unique In This Context"

9. EDBEngineError "Invalid File Name"

10. "Invalid index/tag name."

11. Table name is "GROUP"

12. Getting "long" file names


Powered by phpBB® Forum Software