Solved

How to validate atleast one radio button is checked in a groupbox in C#?

Posted on 2008-10-26
9
910 Views
Last Modified: 2013-11-26
How to validate atleast one radio button is checked in a groupbox in C#?
0
Comment
Question by:JesuSingarayar
  • 4
  • 4
9 Comments
 
LVL 42

Expert Comment

by:dqmq
ID: 22810286
If you set the default value of the groupbox, does that not guarantee that one of the radio buttons is always selected?  
0
 
LVL 8

Expert Comment

by:rpkhare
ID: 22810323
Yes, set the Default Property of one of the radio button to True.
0
 

Author Comment

by:JesuSingarayar
ID: 22810331
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.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 8

Expert Comment

by:rpkhare
ID: 22810360
In that case you need to write the code. Something like this:

if (!radioButton1.Checked && !radioButton2.Checked)
        //Nothing Selected
else
       //Something selected
0
 

Author Comment

by:JesuSingarayar
ID: 22810391
Thanks rpkhare,
Is there any code like...
if (!grpbox1.Checked == true)
{
msgbox ("can can you enter a value");
}
0
 
LVL 8

Expert Comment

by:rpkhare
ID: 22810465
GroupBox is not checked or UnChecked. Alternatively,

if (!radioButton1.Checked && !radioButton2.Checked)
       GroupBox1.Enabled = false;
else
       GroupBox1.Enabled = true;
0
 

Author Comment

by:JesuSingarayar
ID: 22810511
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?
0
 
LVL 8

Accepted Solution

by:
rpkhare earned 125 total points
ID: 22810519
Please look at the solution provided by Morten Wennevik in the below link:
http://bytes.com/forum/thread261844.html

And also,
http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_22589784.html
0
 

Author Comment

by:JesuSingarayar
ID: 22810620
Thank YOU rpkhare!!!
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question