RadToggleButton Bug.

2 posts, 0 answers
  1. Hugues
    Hugues avatar
    54 posts
    Member since:
    Sep 2014

    Posted 06 May 2015 Link to this post

    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);

     

  2. Dimitar
    Admin
    Dimitar avatar
    1414 posts

    Posted 11 May 2015 Link to this post

    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.

     
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top