Solved

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

Posted on 2008-10-26
9
925 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Open dialog with server side controls in it 3 46
IEnumerable<T> to a List<T> 8 51
JQuery Detecting page post back 6 19
Return array 3 19
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

713 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