Click here to Skip to main content
15,883,705 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hellow Guys,

I'm a having a problem in validating radiobuttons in a groupbox.
There are 4 radiobuttons in a groupbox, now i want to check if there is no checked radiobuttons in the groupbox...
and so on to the following groupboxes.
Then after a click a reset button i want to unchecked all the radiobuttons.

Please help...

Thanks in advanced....
Posted

Well, you have not stated what you have tried and where was the issue when you tried it.

Have a look at these article on how radio buttons are grouped:
Gropu Radio Button[^]
How to group RadioButtons[^]

They are more than enough to understand the logic which can be used for coding your scenario.

UPDATE:
Ok. Fine, try this: (it's in C# that I am writing):
C#
// Do this for getting checked status of all radio buttons
// Similar approch can be done to RESET an uncheck them all
for(int i=0;i<myGroupBox.Controls.Count;i++)
{
   RadioButton rb= (RadioButton)myGroupBox.Controls[i];
   if(rb.checked==true)
   {
      // do whatever
      // use break; if needed
      // increase a counter if you want number
   }
}
 
Share this answer
 
v2
Comments
jleonorlane 29-Jul-10 11:07am    
Reason for my vote of 3
..cause i cant see the solution for my problem,even a clue ...
thank u by the way..
Sandeep Mewara 29-Jul-10 11:26am    
This is a specific scenario and exact code should not be expected. If, you are unable to do what you posted then the above links can tell how that can be done. As said, logic couldbe derived from there.
Yet thanks for comment. I will keep in mind for next time with you.
jleonorlane 29-Jul-10 12:02pm    
..by the way,sorry...i just cant find any answers for my problem...
Sandeep Mewara 29-Jul-10 12:17pm    
Ok. Fine. Updated my answer by a small code snippet. Try it.
Sandeep Mewara 29-Jul-10 13:27pm    
Now, was that fine?
Iterate over the children of the groupboxes and check if they are 1) radiobuttons and 2) unchecked.
 
Share this answer
 
Comments
jleonorlane 29-Jul-10 11:58am    
..thats the problem ....HOW..?
Sandeep Mewara 29-Jul-10 12:01pm    
OP needs *exact* code, please provide. :)
AspDotNetDev 29-Jul-10 12:08pm    
With VB.Net, I presume. Or, did you have a more specific question?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900