I usually creates a group of controls for each radio button choice, and hide the other inactive two.
Have Forms never gotten anything like binding in WPF?


Im trying to get different toppings to show up depending on the meal chosen, but nothing seems to be working. Any help will be appreciated. Here is the code….
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

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

private void btnExit_Click(object sender, EventArgs e)
{
Close();
}
private void rdoHamburger_CheckedChanged(object sender, EventArgs e)
{
if (rdoHamburger.Checked)
{
ClearTotals();
gbxAddOn.Text = “Add-on items ($0.50/each)”;
chkBox1.Text = “Pepperoni”;
chkBox2.Text = “Sausage”;
chkBox3.Text = “Olives”;

}
}

private void rdoPizza_CheckedChanged(object sender, EventArgs e)
{

if (rdoPizza.Checked)
{
ClearTotals();
gbxAddOn.Text = “Add-on items ($.25/ each)”;
chkBox1.Text = “Croutons”;
chkBox2.Text = “Bacon Bits”;
chkBox3.Text = “Bread Sticks”;

}
}

private void rdoSalad_CheckedChanged(object sender, EventArgs e)
{
//check the text of the group box and the add ons when salad is selected in the main course
if (rdoSalad.Checked)
{
ClearTotals();
gbxAddOn.Text = “Add-on items ($.25/each)”;
chkBox1.Text = “Croutons”;
chkBox2.Text = “Bacon bits”;
chkBox3.Text = “Bread sticks”;
}
}

private void Form1_Load(object sender, EventArgs e)
{
rdoHamburger.Checked = true;

}

private void btnPlaceOrder_Click(object sender, EventArgs e)
{
double subtotal = 0;
double taxAmount = 0;
double total = 0;
//if hamburger is selected for main course
if (rdoHamburger.Checked)
{
subtotal = subtotal + 6.95;
//if addon is checked add 0.75 to subtotal
if (chkBox1.Checked)
subtotal = subtotal + 0.75;
if (chkBox2.Checked)
subtotal = subtotal + 0.75;
if (chkBox3.Checked)
subtotal = subtotal + 0.75;
}
// Now for the pizza if seleceted
else if (rdoPizza.Checked)
{
subtotal = subtotal + 5.95;
if (chkBox1.Checked)
subtotal = subtotal + 0.50;
if (chkBox2.Checked)
subtotal = subtotal + 0.50;
if (chkBox3.Checked)
subtotal = subtotal + 0.50;
}
else if (rdoSalad.Checked)
{
subtotal = subtotal + 4.95;
if (chkBox1.Checked)
subtotal = subtotal + 0.25;
if (chkBox2.Checked)
subtotal = subtotal + 0.25;
if (chkBox3.Checked)
subtotal = subtotal + 0.25;
}
//get the tax amount
taxAmount = subtotal * (7.75 / 100);
//order total
total = subtotal + taxAmount;
//display to totals
lblSubtotal.Text = subtotal.ToString();
lblSalesTax.Text = taxAmount.ToString();
lblOrderTotal.Text = total.ToString();

}
private void ClearTotals()
{
chkBox1.Checked = false;
chkBox2.Checked = false;
chkBox3.Checked = false;
lblSubtotal.Text = “”;
lblSalesTax.Text = “”;
lblOrderTotal.Text = “”;
}
}

}
So I pretty much turned in this same project two weeks ago here is my code. Obviously different values and naming but its the same thing
if (rdoAdult.Checked)
{
gbxDiscount.Text = “Discount (less $4 each)”;
chkDiscount1.Text = “Military”;
chkDiscount2.Text = “Senior”;
chkDiscount3.Text = “One Year Contract”;
}
else if (rdoFamily.Checked)
{
gbxDiscount.Text = “Discount (less $3 each)”;
chkDiscount1.Text = “One Year Contract”;
chkDiscount2.Text = “4 or more members”;
chkDiscount3.Text = “Military”;
}
else if (rdoYouth.Checked)
{
gbxDiscount.Text = “Discount (less $2 each)”;
chkDiscount1.Text = “High School Graduate”;
chkDiscount2.Text = “College Graduate”;
chkDiscount3.Text = “One Year Contract”;
}

// call methods to clear label boxes and check boxes
ClearDiscounts();
ClearTotals();
}
So do I have to put all of that into one event? Im still confused cause everything seems fine, its just that the checkboxes wont change names when clicking different radio buttons
just so im clear, do you want the checkboxes to change, after pressing the “place order” button, depending on your radio selection, or do you want them to change the moment you click on one of the radio buttons?
I would like the checkboxes to change as soon as I hit a different radio button. Like clicking on hamburgers would bring up add ons for that and clicking on pizza would bring up a different set of addons.


Right now the checkboxes are just staying the same way as the picture and not changing.
C# devs
null reference exceptions

source