Home > DeveloperSection > Forums > How do I get the value of the radio button?
Chintoo Semi

Total Post:135

Posted on    December-17-2013 12:40 AM

 C# C# 

 1 Reply(s)
 709  View(s)
Rate this:

Here are my options (names) for the radio button:






I tried using this but it's giving me an error:

multiplier = Convert.ToDouble(radioButton1.SelectedItem.ToString());

Error Message:

'System.Windows.Forms.RadioButton' does not contain a definition for 'SelectedItem' and no extension method 'SelectedItem' accepting a first argument of type 'System.Windows.Forms.RadioButton' could be found (are you missing a using directive or an assembly reference?)

How do I set the value of the multiplier based on what the user set in the radio button?

Pravesh Singh

Total Post:411

Posted on    December-17-2013 1:22 AM

Hi Chintoo,

As said in the error message, RadioButton has no SelectedItem property. You should be getting the radiobutton text instead.

multiplier = Convert.ToDouble(radioButton1.Text);

If you want to check if the radiobutton is selected, use Checked property instead

if (radioButton1.Checked)


    multiplier = Convert.ToDouble(radioButton1.Text);


In your case you could use a loop

foreach (RadioButton d in this.Controls.OfType<RadioButton>())


    if (d.Checked)


         multiplier = Convert.ToDouble(d.Text);



Don't want to miss updates? Please click the below button!

Follow MindStick