Radio Button Checked Change Event cancel

Joined
Mar 9, 2011
Messages
1
Reaction score
0
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top