private void button1_Click(object sender, EventArgs e) { int a = Convert.ToInt32(textBox1.Text); int b = Convert.ToInt32(textBox2.Text); Drobi d = new Drobi(a, b); listBox1.Items.Add(d);//zapisivaem obyekt v list box }
private void button2_Click(object sender, EventArgs e) { double d = 0; for (int i = 0; i < listBox1.Items.Count; i++) { Drobi s = listBox1.Items[i] as Drobi;// izzvlekaem obyekt iz list boxa d += s.Rezult(); } textBox3.Text = d.ToString(); }