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

I have created 6 panel dynamically in one main panel, using for each panel i have created 1 radio button.I want to grouping of all six radio button. so user can only select 1 radio button at a time.

any one can help me.

Thanks in advance.

1 solution

For this purpose, use the control System.Windows.Forms.GroupBox, please see[^].

During dynamic creation, add all mutually exclusive choices by RadioButton as children of the same instance of GroupBox using Control.Controls.Add or by setting value of the property Control.Parent of each RadioButton to the same instance of GroupBox, see:[^].

Doing it dynamically is not harder than what you already done.


By the way, you could do exact same thing using Panel as a container for your radio buttons. The only reason to use an instance of the GroupBox is to give a common text label to the group (the property GroupBox.Text). You can also use "&" prefix to one character of a label text (as you would do with usual labels (Label class); then it will serve as a hot key for a whole group.

Share this answer

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