由於缺少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()
沒有工作。
什麼不工作有關'CTYPE(cmbCombobox.SelectedItem,clComboboks).value的()'?你意識到它說clCombobo ** ks **它應該是clCombobo ** x **? – MarioDS
是的,我的不好。請在下面查看我的回答。 – janlindso