我收到此错误“运营商'='未定义类型'CivilStatus'并输入'整数'。”
代码:
Private Sub cboCivilStatus_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboCivilStatus.SelectedValueChanged
If cboCivilStatus.SelectedValue = 2 Then
dtpDateMarried.Enabled = True
Else
dtpDateMarried.Enabled = False
End If
End Sub
答案 0 :(得分:2)
好的,你应该尝试使用Combobox SelectedIndexChanged事件
Private Sub cboCivilStatus_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cboCivilStatus.SelectedIndexChanged
If cboCivilStatus.Text = "2" Then
dtpDateMarried.Enabled = True
Else
dtpDateMarried.Enabled = False
End If
End Sub
答案 1 :(得分:0)
看起来SelectedValue
包含类CivilStatus
的对象。如果您要查找所选项目的索引,请改为使用cboCivilStatus.SelectedIndex
属性:
If cboCivilStatus.SelectedIndex = 2 Then
但是如果您需要CivilStatus
的属性,则需要检查该属性,例如
If CType(cboCivilStatus.SelectedValue, CivilStatus).MyIntProperty = 2 Then