Thanks. 
That's exactly what I was looking for.

Thanks also to Steven and Luthfi that came up with the same solution.





"Ross Levis" <[EMAIL PROTECTED]> 
Sänt av: [EMAIL PROTECTED]
2008-01-31 14:12
Sänd svar till
"Borland's Delphi  Discussion List" <[email protected]>


Till
"'Borland's Delphi  Discussion List'" <[email protected]>
Kopia

Ärende
RE: Objects from a TList into a TCombobox






You can use the Items.Objects[] array to store a pointer to the TList
object.
ComboBox1.Items.AddObject('Description', Object1);

Ross.

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On 
Behalf
Of Jesper Stenlund
Sent: Wednesday, 30 January 2008 10:50 p.m.
To: [email protected]
Subject: Objects from a TList into a TCombobox

Hi all.

I have a TList with a bunch of objects and I want to use a ComboBox to 
display them and let the user select the object to work with.

Getting the information into the combo is of course no problem but what is 

the smartest way to keep the connection between an item in the combo and 
the object in the TList?
If I have a TListView instead it's much easier. Just use the property 
"Data" on the TListItem that is added and let it point to the object in 
the TList.

Of course I can use the index of the selected item in the combo and then 
pick out the item with the corresponding index in th TList, but what if 
the combobox is sorted? 

Is there an easy, smart and nice way to do this?

_______________________________________________
Delphi mailing list -> [email protected]
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi

_______________________________________________
Delphi mailing list -> [email protected]
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi

Reply via email to