Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When you set Checked property in a RadioBox, can you suppress the CheckChanged event?

Tags:

c#

.net

winforms

I'm new to C# and Windows Form but if I have a radiobutton and I call radiobutton1.Checked=true, is there a way for it to not fire the CheckedChange event? I want to distinguish between the user clicking on the radiobutton and me setting the radiobutton programmatically. Is this possible?

like image 846
genomess Avatar asked Sep 17 '10 01:09

genomess


People also ask

Which event is achieved when a radio button is selected?

You can use the onchange event, which will fire when the radio selection is changed (ie. the first time a radio button in the group is clicked or when the selection within the group is changed).

What is radio button in c sharp?

In C#, RadioButton is a class and it is defined under System.Windows.Forms namespace. In RadioButton, you are allowed to display text, image, or both and when you select one radio button in a group other radio buttons automatically clear.

How to create radio button dynamically in c#?

Add(new RadioButton() { Text = "RadioButton" + i }); } this. Controls. Add(pnl);


1 Answers

Stop trying to defeat the design of the CheckedChanged event. It's specifically supposed to include programmatic changes.

If you want user-triggered changes and not programmatic changes, use the Click event instead. (You may be thinking that you don't want to restrict yourself to mouse clicks, don't worry, there's a MouseClick event for that, Click includes keyboard changes as well.)

like image 158
Ben Voigt Avatar answered Sep 28 '22 20:09

Ben Voigt