Solved

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

Posted on 2008-10-26
9
933 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
Industry Leaders: 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

Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

707 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