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

Which RadioButton was clicked?

2 Answers 141 Views
Buttons, RadioButton, CheckBox, etc
This is a migrated thread and some comments may be shown as answers.
OverCoded
Top achievements
Rank 2
OverCoded asked on 03 Jun 2010, 03:36 PM
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 Answers, 1 is accepted

Sort by
0
OverCoded
Top achievements
Rank 2
answered on 03 Jun 2010, 03:56 PM
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);

 

    }

 

}

0
Emanuel Varga
Top achievements
Rank 1
answered on 22 Jul 2010, 09:26 AM
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
Tags
Buttons, RadioButton, CheckBox, etc
Asked by
OverCoded
Top achievements
Rank 2
Answers by
OverCoded
Top achievements
Rank 2
Emanuel Varga
Top achievements
Rank 1
Share this question
or