I've got this error "Operator '=' is not defined for type 'CivilStatus' and type '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
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
. If you're looking for Index of the selected item, use cboCivilStatus.SelectedIndex
property instead:
If cboCivilStatus.SelectedIndex = 2 Then
But if you need a property of CivilStatus
you need to check against that property, eg
If CType(cboCivilStatus.SelectedValue, CivilStatus).MyIntProperty = 2 Then
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.