|
-
January 7th, 2013, 03:46 PM
#9
Re: Radiobuttons
 Originally Posted by Dritech
That's what I was trying to do. I solved the problem by using 'button.Enabled = false;' as shown below:
Code:
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
button1.Enabled = true;
button2.Enabled = true;
button3.Enabled = true;
button4.Enabled = false;
button5.Enabled = false;
button6.Enabled = false;
}
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
button1.Enabled = false;
button2.Enabled = false;
button3.Enabled = false;
button4.Enabled = true;
button5.Enabled = true;
button6.Enabled = true;
}
That's one approach but it doesn't scale well. Consider what would happen if you had two groups of 5 radio buttons managing the enable/disable state of 10 buttons each?
Check out the two sample code projects in the link I posted and try to understand those approaches. Both eliminate the need to create check changed handlers for every radio button which should result in smaller, more maintainabile code.
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
|