Windows Form Group Box

G

Guest

if you put three Radio Buttons in a group box. Is there a way to use the
group box control to check an see which radio button is selected. Instead of
having to check each radio button to see if it is selected?

C# Please.

Thanks
 
D

Darren Shaffer

there is no group box control in the .Net Compact Framework, however
if you place multiple radio buttons on a form or panel, their boolean state
behaves as a group but you do need to interrogate each one to determine
which (if any) is checked.

-Darren
 
G

Guest

well if you don't interrogate each one, then how can you find out which one
is checked?

Code Example please.
 
D

Duncan Mole

you could write a genic method for this such as below (not tested)

public RadioButton GetSelected(Control owner)
{
foreach(Control control in owner.Controls)
{
if(control is RadioButton)
{
RadioButton candidate = (RadioButton)candidate;
if(candidate.Checked)
return candidate;
}
}
return null;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top