-2

I currently have 3 radio buttons in 3 groups, and I just needed to pull the text value from the currently checked radio button in the each group and store it in the decimal value. Any ideas?

My current code:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {

    }

    private void label4_Click(object sender, EventArgs e)
    {

    }

    private void radioButton1_CheckedChanged(object sender, EventArgs e)
    {

    }

    private void btnCalculate_Click(object sender, EventArgs e)
    {
        decimal loanAmount; 
        decimal interestRate;
        Int16 numberOfPayments;
        decimal monthlyPayment;

        // create the web service object
        ISULoanLeaseCalculatorService myCalcWS = new ISULoanLeaseCalculatorService();

        monthlyPayment = (decimal)myCalcWS.LoanMonthlyPayment(
        Convert.ToDouble(loanAmount),
        Convert.ToDouble(interestRate),
        Convert.ToDouble(numberOfPayments));

    }
}
Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574

1 Answers1

1

You can react to the CheckedChanged event whenever a button is clicked.

Then grab the text associated with the button from the Text property and try to parse it:

decimal myDecimalValue;

bool success = decimal.TryParse(rb.Text, out myDecimalValue);
if (!success) ShowSomeErrorMessage();
Eric J.
  • 147,927
  • 63
  • 340
  • 553