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?
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).
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.
Add(new RadioButton() { Text = "RadioButton" + i }); } this. Controls. Add(pnl);
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.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With