using Microsoft.VisualBasic; namespace WinFormsApp1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { listBox1.Items.Add("Salade"); listBox1.Items.Add("Fromage"); listBox1.Items.Add("Poulet Routis"); listBox1.Items.Add("Poisson"); listBox1.Items.Add("Dessert"); listBox1.Items.Add("Café"); listBox1.SelectionMode = SelectionMode.MultiSimple; listBox2.Items.Add("Premier classe"); listBox2.Items.Add("Deuziéme classe"); comboBox1.Items.Add("Pas de réduction"); comboBox1.Items.Add("Carte jeune"); comboBox1.Items.Add("Carte adulte"); comboBox1.Items.Add("Carte famille"); } private void button1_Click(object sender, EventArgs e) {/* foreach (var elem in listBox1.SelectedItems) { MessageBox.Show("votre choix est: " + elem.ToString()) ; } */ /*string message; message = "Votre plat comporte: \n \n "; foreach (var elem in listBox1.SelectedItems) { message += "-" + " " + elem.ToString() + "\n"; } MessageBox.Show(message);*/ if (listBox1.SelectedItems.Count > 0) { string message; message = "Votre plat comporte: \n \n "; foreach (var elem in listBox1.SelectedItems) { message += "-" + " " + elem.ToString() + "\n"; } MessageBox.Show(message); } else { MessageBox.Show("Auccun plat"); } } private void groupBox1_Enter(object sender, EventArgs e) { } private void textBox3_TextChanged(object sender, EventArgs e) { } private void button3_Click(object sender, EventArgs e) { textBox4.Text = ""; textBox1.Text = ""; } private void button2_Click(object sender, EventArgs e) { float pb; pb = float.Parse(textBox4.Text); if (listBox2.Text=="Premier classe") { pb += pb * 20 / 100; } if (comboBox1.Text=="Carte adulte") { pb = pb - (pb * 30 / 100); } if (comboBox1.Text == "Carte jeune") { pb = pb - (pb * 40 / 100); } if (comboBox1.Text == "Carte famille") { pb = pb - (pb * 50 / 100); } textBox1.Text = pb.ToString(); float tva; tva = pb * 20 / 100; textBox2.Text = tva.ToString(); float ttc; ttc = pb + tva; textBox3.Text = ttc.ToString(); } } }