.netwinformsradio-buttonradiobuttonlistgroupname

Group 2 radiobuttons into the same group for Windows application


I have a question on how to group 2 radiobuttons into the same group for Windows application.

I googled, usually there are 2 solutions:

I also find someone saying:
just setting the GroupName attributes of the 2 radiobuttons to be the same name, then .net will regard them of the same group.

However, this radiobutton attribute comes starting from .net 3.0. And I find the radiobutton component in the toolbox is of .Net 2.0.

So I guess the solution is:
to add radiobutton of .Net 3.0 to Toolbox and use this radiobutton while building the layout of the WinForm, then the attribute will appear.

But I cannot find relevant item in the "Choose Toolbox Items" Dialog box and don't know the name and the path of the System.Windows.Forms dll.

Anyone has idea?

Also, is there any other way to group 2 radiobuttons into the same group (especially without using GroupBox or panel)?

PS: My Windows application project's Target Framework is set to .Net 3.5 originally, and I cannot find the GroupName attribute of a RadioButton on a WinForm. When I hover on the RadioButton component in Toolbox, it shows it's of .Net 2.0.

Thanks for help in advance.


Solution

  • You don't have to look for the .net 3.0 radio button.( I don't even think there's such thing.) All you have to do is set your build target at the project level and everything should be ok.

    To do so, right click the project name, click on Properties and under the Application menu you'll see a Target framework dropdown. Select the wanted .NET Framework from there.

    Please be aware that the GroupName is available only in WPF. For WinForms you can use GroupBox or a Panel control to have them grouped however you want.(Just tried it and it's working). More options on this problem can be found on this question