Combobox in C# : how to add for each Item a Tag ?
-
Hi, I looking to storing some datas to a combobox with for each datas a would like to store a Tag value. Best regrads youssef
Create a custom object collection where your objects show all the info u need through properties. Then set the collection as ur combo's datasource and set the displaymember and valuemember to your object's properties (Name and Tag for example). If u dont want to go through all that, it might be easier to just store all objects + info in the necessary fields of a datatable (that would solve ur custom object collection) and proceed the same way as before.
-
Hi, I looking to storing some datas to a combobox with for each datas a would like to store a Tag value. Best regrads youssef
For more information and an example of what Skynyrd mentioned, read about the MappingName Property[^] for the
DataGridTableStyle
class in the .NET Framework SDK. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles] [My Blog] -
Hi, I looking to storing some datas to a combobox with for each datas a would like to store a Tag value. Best regrads youssef
You can add any object as an item to a
ComboBox
, and to display it, theComboBox
calls the object'sToString
method. So, create aMyComboItem
class that contians two (or more) properties,Text
andTag
, and overrideToString
to return the contents of theText
property. When you get an item from theComboBox
'sItems
collection, don't forget to do the appropiate cast. -- LuisR
Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!