Solved

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

Posted on 2008-10-26
9
891 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now