I found a way to include my items dynamically by following this how-to:
http://www.mgbrown.com/PermaLink37.aspx
If you dont want to take a look on the link here it goes:
Expand|Select|Wrap|Line Numbers
- Public Class ValueDescriptionPair
- '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- 'Class used to control the comboBox components
- '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- 'Usage:
- 'To add items to the list you use code like this:
- '
- 'ComboBox1.Items.Add(New ValueDescriptionPair(1, "first item"))
- 'ComboBox1.Items.Add(New ValueDescriptionPair(2, "second item"))
- 'ComboBox1.Items.Add(New ValueDescriptionPair(3, "third item"))
- '
- 'To get the value stored in Value and displays in a message box:
- 'Dim ItemSelected As Integer
- 'ItemSelected = CType(ComboBox1.SelectedItem,ValueDescriptionPair).Value
- 'MsgBox("Value Selected = " & ItemSelected)
- '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- Private m_Value As Object
- Private m_Description As String
- #Region "properties"
- Public ReadOnly Property Value() As Object
- Get
- Return m_Value
- End Get
- End Property
- Public ReadOnly Property Description() As String
- Get
- Return m_Description
- End Get
- End Property
- #End Region
- Public Sub New(ByVal NewValue As Object, ByVal NewDescription As String)
- m_Value = NewValue
- m_Description = NewDescription
- End Sub
- Public Overrides Function ToString() As String
- Return m_Description
- End Function
- End Class
For example, I did:
Expand|Select|Wrap|Line Numbers
- CmbBoxType.Items.Add(New ValueDescriptionPair(1, "Type 1"))
- CmbBoxType.Items.Add(New ValueDescriptionPair(2, "Type 2"))
How would you know the reference to your ValueDescriptionPair like this?
thanks