Hi
I have two radio buttons. I fhte user swtich between radio buttons, I need to popup warning message and if user confirm, then only I need to swtich to next radio button. Otherwise I shouldnt switch. I am using CheckedChanged event. As by the time I popup warning message, control is already switched. I tried adding and removing event handler.
Private Sub opt_CheckedChanged (ByVal sender As System.Object, ByVal e As System.EventArgs)
m_result = MessageBox.Show("Are you sure want to change....
If (m_result = DialogResult.Yes) Then
'Go ahead and switch....
else
Dim cb As Radiobutton = CType(sender, RadioButton)
RemoveHandler cb.CheckedChanged, AddressOf opt_CheckedChanged
cb.Checked = Not cb.Checked
AddHandler cb.CheckedChanged, AddressOf opt_CheckedChanged
End if
End sub
Even when I add and remove handler, still checkedchanged event fired twice (first time for opt1 uncheck and second for opt2 check. If I do cb.checked = not cb.unchecked, it fires again regardless of removing eventhandler)
Any suggestions to achive this please?
I have two radio buttons. I fhte user swtich between radio buttons, I need to popup warning message and if user confirm, then only I need to swtich to next radio button. Otherwise I shouldnt switch. I am using CheckedChanged event. As by the time I popup warning message, control is already switched. I tried adding and removing event handler.
Private Sub opt_CheckedChanged (ByVal sender As System.Object, ByVal e As System.EventArgs)
m_result = MessageBox.Show("Are you sure want to change....
If (m_result = DialogResult.Yes) Then
'Go ahead and switch....
else
Dim cb As Radiobutton = CType(sender, RadioButton)
RemoveHandler cb.CheckedChanged, AddressOf opt_CheckedChanged
cb.Checked = Not cb.Checked
AddHandler cb.CheckedChanged, AddressOf opt_CheckedChanged
End if
End sub
Even when I add and remove handler, still checkedchanged event fired twice (first time for opt1 uncheck and second for opt2 check. If I do cb.checked = not cb.unchecked, it fires again regardless of removing eventhandler)
Any suggestions to achive this please?