[英]vb.net combobox selectedvalue event error
I've got this error "Operator '=' is not defined for type 'CivilStatus' and type 'Integer'." 我收到此错误“没有为类型'CivilStatus'和类型'Integer'定义运算符'='。”
Code: 码:
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
Ok, you should try using the Combobox SelectedIndexChanged Event 好的,您应该尝试使用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
It looks like SelectedValue
contains an object of class CivilStatus
. 看起来SelectedValue
包含一个CivilStatus
类的对象。 If you're looking for Index of the selected item, use cboCivilStatus.SelectedIndex
property instead: 如果要查找所选项目的索引,请改用cboCivilStatus.SelectedIndex
属性:
If cboCivilStatus.SelectedIndex = 2 Then
But if you need a property of CivilStatus
you need to check against that property, eg 但是,如果您需要CivilStatus
的属性, CivilStatus
需要检查该属性,例如
If CType(cboCivilStatus.SelectedValue, CivilStatus).MyIntProperty = 2 Then
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.