By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,896 Members | 2,002 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,896 IT Pros & Developers. It's quick & easy.

RadioButton Change validation

P: n/a
Hi
I have 2 radio buttons and want to perform some kind of validation before I
allow the checked state to move from one to another. I tried overriding the
validating callback but I noticed that it is called when loosing focus and
that is not good enough because I need to know when one radio button is
checked.
The only way I found is to create a class deriving from RadioButton and I
override the OnClick event. I have an event handler that you can register to
and can confirm of the click should be performed or not.

Isnt there any built in way to handle this. ?

public class ControlledRadioButton : RadioButton
{

public delegate bool ConfirmClick(EventArgs e);
public event ConfirmClick ConfirmClickEvent = null;
protected override void OnClick(EventArgs e)
{
if(ConfirmClickEvent == null || ConfirmClickEvent(e))
base.OnClick(e);
}
}
Thanks

Sep 26 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.