Hello,
I am currently working on Winforms, and I have 3 radio buttons that will have different values.
this is what I have on MainForm.cs, but I want to move this over to another class:
public double RadioValue
{
get
{
if (radioOne.Checked) return 1.56;
if (radioTwo.Checked) return 4.1;
if (radioThree.Checked) return 4.2;
return 0;
}
}
Loading
Wim SturkenboomPosted Oct 26, 2014, 12:39 AM
class Logic
{
public static double RadioValue(bool fR1, bool fR2, bool fR3)
{
if (fR1) return 1.56;
if (fR2) return 4.1;
if (fR3) return 4.2;
return 0;
}
}
The method takes three bools (representing the values of the three radiobuttons).
In the form (example below uses a button to get the double value), you can call the method as shown
private void button1_Click(object sender, EventArgs e)
{
double val = Logic.RadioValue(radioButton1.Checked, radioButton2.Checked, radioButton3.Checked);
label1.Text = val.ToString();
}
You can put all your logic methods in the logic class.
Song LeePosted Oct 26, 2014, 9:35 PM