RadioButton Group

Answered
0
0

Dear Team,

 

Currently the RadioButtons are grouped by the ownership in a container.

If I have two or more RadioButton groups in one form, I need to place the RadioButtons into separate sub-containers, thus limiting my control layout options.

Is there an easy way to group siblings, without nesting containers?

 

I wonder if you could add a “RadioButtonGroup” property to the RadioButton control.

This would work like this:

rbOptionA1.RadioButtonGroup = “GroupA”;

rbOptionA2.RadioButtonGroup = “GroupA”;

rbOptionA3.RadioButtonGroup = “GroupA”;

rbOptionB1.RadioButtonGroup = “GroupB”;

rbOptionB2.RadioButtonGroup = “GroupB”;

rbOptionB3.RadioButtonGroup = “GroupB”;

 

Thanks,

Kizameon

  • You must to post comments
Great Answer
0
0

Hi Kizameon,

Thank you for the detailed description.

The RadioButton control is supposed to be part of a visible container (Panel/Groupbox) just like in WinForms.

In Wisej, RadioButton controls have the AutoCheck property which Returns or set a value indicating whether the Checked or Checked values and the RadioButton’s appearance are automatically changed when the RadioButton itself is clicked. RadioButton.AutoCheck Property (wisej.com)

The way to get around your issue is to simply set the AutoCheck property to false and with that you can have total control on which radio button to check/uncheck.

You can set your groups by populating the Tag property of the control, but if you’re already using it for other purposes Wisej has the property UserData that you can use to assign your groups. (something like UserData.RadioGroup).

I have attached a sample and used the Tag property to achieve the desired results.

Hope this helps, let me know if you need anything else.

Best wishes,
Alaa

  • Kizaemon Date
    Dear Alaa, thank you this is a good starting point! I will work on my own derived control to cover all I need. Again, your example is a great starting point, but I wanted to mention several problems with how it is right now: 1) The change works only on click or arrow key focus move (e.g. left-right). It does not do well when setting the Checked property (e.g. rbSizeLarge.Checked = true) 2) The TabStops/Focus are not handled well between the groups. (Arrow Keys should rotate inside a group, Tab should switch between the groups) 3) The handling code is quite verbose, so I will hide all the plumbing into some private methods of the derived control (e.g. RadioButtonExt) Great, thank you very much! Kizaemon
  • You must to post comments
0
0

Hi Alaa,

 

please see the picture attached for sample demonstration.

 

I have added 6 radio buttons in one container.

 

Color: ( ) Red ( ) Green ( ) Blue

Size: ( ) Small ( ) Medium ( ) Big

 

Because the 6 radio buttons are located insde one container (e.g. Group Box), I can only select one radio button at a time out of six.

I cannot select combination of one Size and one Color.

In order to do so, I need to create sub-containers (panels or grou boxes) for each radio button group.

 

There could be an easier way to do so.

For example the pure HTML input type=radio has the name attribute, which allows easy grouping of the radiobuttons.

 

<input type=”radio” id=”id1″ name=”color” value=”Red”>

<input type=”radio” id=”id2″ name=”color” value=”Green”>

<input type=”radio” id=”id3″ name=”size” value=”Small”>

<input type=”radio” id=”id4″ name=”size” value=”Big”>

 

The WiseJ RadioButton control can get a handy property GroupName, which will be used for iteration in order to find the next radiobutton in the group.

Hopefully this helps.

  • You must to post comments
0
0

Hi Kizameon,

Can you please give us more details on what you’re trying to achieve ?

Thank you,
Alaa

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.