[RESOLVED] [2.0] radio button which event when the user clicks on it?
I am having 2 radio buttons on my windows form (C#). when the user clicks on a radio button I want some code to run.
In which event of the radio button I should write the code?
I tried in Checkedchanged event of the radio button, whenever the user clicks on the other radio button, this event gets triggered. I want the code to be executed only when the user clicks on the radio button and not when the user checks another radio button.
thanks
nath
Re: [2.0] radio button which event when the user clicks on it?
Re: [2.0] radio button which event when the user clicks on it?
I tried putting code in the "Click" event of the radio button and it doesn't work.
private void rdoOnlyBooks_Click(object sender, EventArgs e)
{
}
Re: [2.0] radio button which event when the user clicks on it?
The CheckChanged event is raised whenever the Checked property changes, either from True to False (unchecked) or from False to True (checked). All you have to do is test the current value of the Checked property to know whether the RadioButton is being checked or unchecked. If it is being checked and you didn't do it yourself in code then it's a fair bet that the user just clicked the RadioButton.
Code:
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
if (this.radioButton1.Checked)
{
// The user just clicked the RadioButton.
}
}
Re: [2.0] radio button which event when the user clicks on it?
Sorry, I got my radio buttons and checkboxes muddled up :)