private void button1_Click(object sender, EventArgs e) { tovar tov = new tovar(); Form2 addform = new Form2(tov, true); addform.ShowDialog(); tovars.Add(tov); comboBox1.Items.Add(tov); }
private void button3_Click(object sender, EventArgs e) { if (comboBox1.SelectedItem != null) { listBox1.Items.Add(comboBox1.SelectedItem); tovar tmp = (tovar)comboBox1.SelectedItem; textBox1.Text = tmp.Price.ToString(); total += tmp.Price; textBox2.Text = total.ToString(); } }
private void button2_Click(object sender, EventArgs e) { if (comboBox1.SelectedItem != null) { int n = comboBox1.SelectedIndex; tovar tmp = (tovar)comboBox1.SelectedItem; Form2 editform = new Form2(tmp, false); editform.ShowDialog(); comboBox1.Items.RemoveAt(n); comboBox1.Items.Insert(n, tmp); comboBox1.SelectedItem = comboBox1.Items[0]; } }
public Form2(tovar t, bool addnew) { temp = t; InitializeComponent(); if (addnew == true) { button1.Text = "Add"; } else { button1.Text = "Edit"; textBox1.Text = t.Name; textBox2.Text = t.Descr; textBox3.Text = t.Price.ToString(); } }