|
-
Apr 23rd, 2006, 11:05 AM
#1
Thread Starter
Hyperactive Member
[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
-
Apr 23rd, 2006, 12:13 PM
#2
Re: [2.0] radio button which event when the user clicks on it?
Hmm... "Click" maybe?
-
Apr 23rd, 2006, 05:22 PM
#3
Thread Starter
Hyperactive Member
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)
{
}
-
Apr 23rd, 2006, 06:15 PM
#4
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.
}
}
-
Apr 23rd, 2006, 08:48 PM
#5
Re: [2.0] radio button which event when the user clicks on it?
Sorry, I got my radio buttons and checkboxes muddled up
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|