JesuSingarayar
asked on
How to validate atleast one radio button is checked in a groupbox in C#?
How to validate atleast one radio button is checked in a groupbox in C#?
If you set the default value of the groupbox, does that not guarantee that one of the radio buttons is always selected?
Yes, set the Default Property of one of the radio button to True.
ASKER
I had to make the user to pick ONE option & i didnt want it to be a default one. The problem happens when the user forgets to input any value. I have to catch his mistake and say "hi can can you enter all the values" when she presses output button.Thanks.
In that case you need to write the code. Something like this:
if (!radioButton1.Checked && !radioButton2.Checked)
//Nothing Selected
else
//Something selected
if (!radioButton1.Checked && !radioButton2.Checked)
//Nothing Selected
else
//Something selected
ASKER
Thanks rpkhare,
Is there any code like...
if (!grpbox1.Checked == true)
{
msgbox ("can can you enter a value");
}
Is there any code like...
if (!grpbox1.Checked == true)
{
msgbox ("can can you enter a value");
}
GroupBox is not checked or UnChecked. Alternatively,
if (!radioButton1.Checked && !radioButton2.Checked)
GroupBox1.Enabled = false;
else
GroupBox1.Enabled = true;
if (!radioButton1.Checked && !radioButton2.Checked)
GroupBox1.Enabled = false;
else
GroupBox1.Enabled = true;
ASKER
Please Assume a groupbox has 30 radio buttons And there is no default set.
The user has to pick one in 30 options and click on Execute to to perform a job.
If they haven't picked any of the 30 options. When execute is clicked, msg box should pop up and say " pick up one of the 30 options". How would i do that?
The user has to pick one in 30 options and click on Execute to to perform a job.
If they haven't picked any of the 30 options. When execute is clicked, msg box should pop up and say " pick up one of the 30 options". How would i do that?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank YOU rpkhare!!!