Hi Jesper,
The ComboBox Items is a Tstrings derivative and can take both a string
for display and an object, so you could for instance call
ComboBox.Items.AddObject('A Title',TObject(Tlist[I])) for each item in
your Tlist, that way even if the list is sorted you can access the
object using ComboBox.Items.Objects[ComboBox.ItemIndex] for the selected
item.
Hope this helps
Steve
VT Lifeskills
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Jesper Stenlund
Sent: 30 January 2008 09:50
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?
//Jesper
_______________________________________________
Delphi mailing list -> [email protected]
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi
--------------------------------------------------------------------------------
This Email and any files transmitted with it are confidential and may be
legally
privileged. They are intended for use solely of the intended recipient(s). If
you have
received an Email in error:
(a) any distribution, copying or other use of its contents is prohibited; and
(b) please notify the sender as soon as possible and delete the email and any
associated files and copies from your system.
Any views or opinions expressed are solely those of the author and do not
necessarily represent the views of VT Group plc or any of its subsidiary or
associated companies. If you have any other problems please contact the
Administrator by E-mail ([EMAIL PROTECTED]) or the Service Desk by telephone on
0800 028 1371, or for users abroad 44 (0) 23 9288 3888.
VT Group plc
Company No: 1915771
Registered in England
VT House, Grange Drive, Hedge End, Southampton SO30 2DQ
--------------------------------------------------------------------------------
_______________________________________________
Delphi mailing list -> [email protected]
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi