Which RadioButton was clicked?

3 posts, 0 answers
  1. OverCoded
    OverCoded avatar
    34 posts
    Member since:
    Mar 2010

    Posted 03 Jun 2010 Link to this post

    I have a group of radiobuttons (in a groupbox) I need to know which one is toggled on when the user makes a change. The documentation offers the following code to handle the toggle state change:

     

     

    private void radioBtn_ToggleStateChanged(object sender,Telerik.WinControls.UI.StateChangedEventArgs args)

     

    {

     

     

        <my code here>    

     

    }
    I need to iterate through the radiobuttons to see which one was selected. All the event handler gives me it the toggle state. I am looking for a foreach() to do this.

  2. OverCoded
    OverCoded avatar
    34 posts
    Member since:
    Mar 2010

    Posted 03 Jun 2010 Link to this post

    Disregard, I got it.

    private

     

     

    void radioBtn_ToggleStateChanged(object sender,Telerik.WinControls.UI.StateChangedEventArgs args)

     

    {

     

     

        foreach (RadRadioButton btn in groupBox_SheetLayout.Controls)

     

        {

     

     

            if ( btn.ToggleState == Telerik.WinControls.Enumerations.ToggleState.On )

     

     

     

            MessageBox.Show(btn.Text);

     

        }

     

    }

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 22 Jul 2010 Link to this post

    Hello,

    You could set a tag on the radioButton, and on event just cast the sender and access the tag, you will just eliminate that foreach

    Emanuel
Back to Top