ListBox
//deselect
listBox_pizza.SelectedIndex = -1;
//add 1 item
lb_orderQuantity.Items.Add(listBox_salad.SelectedItem);
// remove item
lb_orderQuantity.Items.Remove(lb_orderQuantity.SelectedItem);
// remove all items
listBox1.Items.Clear();
//if not selected
if (lb_orderQuantity.SelectedIndex != -1)
{
// selected
}
//loop through all items
subtotal = 0;
foreach (var listBoxItem in lb_orderQuantity.Items)
{
string item = listBoxItem.ToString().Substring(0, 3);
switch (item)
{
case "Pep": subtotal = subtotal + PEPPERONI_PIZZA_PRICE; break;
case "Mus": subtotal = subtotal + MUSHROOM_PIZZA_PRICE; break;
case "Gar": subtotal = subtotal + GARDEN_SALAD_PRICE; break;
case "Cae": subtotal = subtotal + CASEAR_SALAD_PRICE; break;
}
}