G
Guest
I have the (usual) problem that, in a combo or listbox, I want to keep a text
and a related key value. For instance the country description and the country
code.
In order to solve this I uss the following approach:
With the following class I create an item
#Region "Create SubClass Item"
Public Class KeyItem
Inherits ListViewItem
Public ItemKey As String
Public ItemText As String
Sub New(ByVal ShowItemKey As String, ByVal ShowItemText As String)
MyBase.New()
ItemKey = ShowItemKey
ItemText = ShowItemText
Me.Text = ItemText
End Sub
End Class
#End Region
then I add records to the combo ...
cmb_country.Items.Add(New KeyItem("NL", "Netherlands"))
Although the values are correctly stored in the combo, when displaying the
values instead of seeing "Netherlands" I see : "ListViewItem: {Netherlands}"
How can I get rid of that "ListViewItem:{" part?
Is there an alternate solution?
Thanks for your help
tino
and a related key value. For instance the country description and the country
code.
In order to solve this I uss the following approach:
With the following class I create an item
#Region "Create SubClass Item"
Public Class KeyItem
Inherits ListViewItem
Public ItemKey As String
Public ItemText As String
Sub New(ByVal ShowItemKey As String, ByVal ShowItemText As String)
MyBase.New()
ItemKey = ShowItemKey
ItemText = ShowItemText
Me.Text = ItemText
End Sub
End Class
#End Region
then I add records to the combo ...
cmb_country.Items.Add(New KeyItem("NL", "Netherlands"))
Although the values are correctly stored in the combo, when displaying the
values instead of seeing "Netherlands" I see : "ListViewItem: {Netherlands}"
How can I get rid of that "ListViewItem:{" part?
Is there an alternate solution?
Thanks for your help
tino