Problem : VB6.SetItemData in ComboBox

Problem : VB6.SetItemData in ComboBox

i upgraded VB6 project to VB.Net. i Kept some unique id’s as ItemData in Combo boxes for each entry in them.
and in i tried


But it returns an error

“Entry in Items array was not of a type supported by Microsoft.VisualBasic.Compatibility.VB6.SetItemData.”

i am missing something?
I made lots of calculations and codings using this itemdata values
please help


Solution: VB6.SetItemData in ComboBox

.NET ComboBox doesn’t support item data. Instead of this, ComboBox allows to keep objects of any type (not only strings). You can create your own class which has ToString function, it will be used for combobox lines. This class can keep any other additional data which you want to keep using SetItemData.

comboBox1.Items.Add(“Item 1”)

Change this to:

comboBox1.Items.Add(new MyItem(“Item 1”, myData));