在缺少Value
属性的情况下,我计划使用类来存储我的物品Text
并使用属性。到目前为止,我已经成功了。Value
ComboBox
这是我的课:
Public Class clCombobox
Public cname As String
Public cvalue As Integer
Public Property Display() As String
Get
Return Me.cname
End Get
Set(ByVal value As String)
Me.cname = value
End Set
End Property
Public Property Value() As String
Get
Return Me.cvalue
End Get
Set(ByVal value As String)
Me.cvalue = value
End Set
End Property
Public Sub New(ByVal name As String, ByVal value As String)
cname = name
cvalue = value
End Sub
Public Overrides Function ToString() As String
Return cname
End Function
End Class
数据被添加到ComboBox
这样的:
cmbComboxBox.Items.Add(New clCombobox("Text", 1))
到目前为止,这似乎有效。但是我如何取回数据。就像我想要所选CheckBox
项目的价值一样?
我尝试使用:
CType(cmbCombobox.SelectedItem, clCombobox).Value()
不工作。