?
Solved

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

Posted on 2008-10-26
9
Medium Priority
?
940 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Automating Terraform w Jenkins & AWS CodeCommit

How to configure Jenkins and CodeCommit to allow users to easily create and destroy infrastructure using Terraform code.

 
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 500 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

762 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