Solution
This is what I came up with:
Public Class IndexedDropDownItem
Private _KeyCode, _Display As String
Public Property KeyCode() As String
Get
Return _KeyCode
End Get
Set(ByVal value As String)
_KeyCode = value
End Set
End Property
Public Property Display() As String
Get
Return _Display
End Get
Set(ByVal value As String)
_Display = value
End Set
End Property
Sub New(ByVal KeyIndex As String, ByVal ItemDisplay As String)
KeyCode = KeyIndex
Display = ItemDisplay
End Sub
Public Overrides Function ToString() As String
Return String.Format("{0} - {1}", KeyCode, Display)
End Function
End Class
Implementation:
With myDropDown
Dim oItem As IndexedDropDownItem = Nothing
For Each dr As Data.DataRow In oTemp.Rows
oItem = New IndexedDropDownItem(dr.Item("key_code"), _
dr.Item("descript"))
.Items.Add(oItem)
oItem = Nothing
Next
End With
Manipulation:
Dim _KeyCode, _Display As String
With CType(dataPathComboBox.SelectedItem, IndexedDropDownItem)
_KeyCode = .KeyCode
_Display = .Display
End With
I hope this will help someone out!
I have a ComboBox that is populated from a DataTable:
With myComboBox
.DataSource = myDataTable
.DisplayMember = "descript"
.ValueMember = "key_code"
End With
I want to be able to have the DisplayMember show "key_code - descript", while retaining the value I have set.
Is this even possible? Thanks