Hi,
Can anybody help me with following problem. I'm trying to use multievent. I created chkMultiUse and I'm trying to use it in sub myClickHandler, nut I'm getting error: Unable to cast object type Buttons to type CheckBox. I know should change in some way chkMultiUse. Please any help will be appreciated.
Thanks, Gigaz
Can anybody help me with following problem. I'm trying to use multievent. I created chkMultiUse and I'm trying to use it in sub myClickHandler, nut I'm getting error: Unable to cast object type Buttons to type CheckBox. I know should change in some way chkMultiUse. Please any help will be appreciated.
Code:
Private Sub chkMultiUse_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles chk1.CheckedChanged, chk2.CheckedChanged, chk3.CheckedChanged
Dim chkMultiUse As CheckBox
chkMultiUse = CType(sender, CheckBox)
If chkMultiUse.Checked Then
AddHandler btnDelete.Click, AddressOf myClickHandler
Else
RemoveHandler btnDelete.Click, AddressOf myClickHandler
End If
End Sub
Private Sub myClickHandler(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim iResponce As Integer
Dim chkMultiUse As CheckBox
chkMultiUse = CType(sender, CheckBox)
iResponce = MsgBox("Are You Sure You want to delete check box", vbYesNo, "DELETE CHECKBOX")
If iResponce = vbYes And chkMultiUse.Checked Then ' They Clicked YES!
chkMultiUse.Visible = False
Else
chkMultiUse.Visible = True
chkMultiUse.Checked = False
End If
End Sub