This is a migrated thread and some comments may be shown as answers.

RadToggleButton Bug.

1 Answer 121 Views
Buttons, RadioButton, CheckBox, etc
This is a migrated thread and some comments may be shown as answers.
Hugues
Top achievements
Rank 1
Hugues asked on 06 May 2015, 09:02 PM

Using the code bellow which add a radio button to a RadToggleButton. Whenever i click the button and not the radio button. The radio button automatically toggles on as well. But if you change RadToggleButton to a RadButton then it works. It also hapens with RadCheckBoxElement as well.

            RadToggleButton button = new RadToggleButton();
            button.Text = "Test";
            
            RadRadioButtonElement e = new RadRadioButtonElement();
            e.ToggleStateChanged += e_ToggleStateChanged;
            e.CheckStateChanged += e_CheckStateChanged;
            e.Margin = new System.Windows.Forms.Padding(button.Width-18, 0, 0, 0);
            button.ButtonElement.Children.Add(e);
            button.ToggleStateChanged += button_ToggleStateChanged;
            Controls.Add(button);

 

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 11 May 2015, 01:01 PM
Hi Hugues,

Thank you for writing.

In this case the only the visual state of the element is changed by the theme. As you can see the ToggleStateChanged event is not fired unless the radio button is clicked. So to avoid this you can use RadHostItem and add RadRadioButton:
RadToggleButton button = new RadToggleButton();
button.Text = "Test";
button.Location = new Point(30, 30);
 
RadRadioButton radio = new RadRadioButton();
 
RadHostItem item = new RadHostItem(radio);
radio.ToggleStateChanged += e_ToggleStateChanged;
radio.CheckStateChanged += e_CheckStateChanged;
 
item.StretchHorizontally = false;
item.StretchVertically = false;
item.Alignment = ContentAlignment.MiddleRight;
item.ShouldHandleMouseInput = true;
item.NotifyParentOnMouseInput = false;
button.ButtonElement.Children.Add(item);
 
Controls.Add(button);

I hope this helps. Should you have any other questions do not hesitate to ask.
 
Regards,
Dimitar
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
Buttons, RadioButton, CheckBox, etc
Asked by
Hugues
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or