private void button1_Click(object sender, EventArgs e) { int num; ushort loc; try { loc = ushort.Parse(textBox3.Text); num = int.Parse(textBox2.Text); Componets cp = new Componets(textBox1.Text, comboBox1.Text, comboBox2.Text, num, richTextBox1.Text, loc, Picture); this.Close(); if (inf == 0) { Form1.al.Add(cp); } else { Form1.al.Insert(Index, cp); } } catch { MessageBox.Show("不要输入错误数据"); } }
public Form2(Componets cp,int Index) { inf = 1; InitializeComponent(); textBox1.Text = cp.Name; comboBox1.Text = cp.Type; comboBox2.Text = cp.Type; textBox2.Text = cp.Pieces.ToString(); textBox3.Text = cp.Location.ToString(); richTextBox1.Text = cp.Information; button1.Text = "修改"; this.Index = Index; }
public Form2(Componets cp, int Index) { inf = 1; InitializeComponent(); textBox1.Text = cp.Name; comboBox1.Text = cp.Type; comboBox2.Text = cp.Type; textBox2.Text = cp.Pieces.ToString(); textBox3.Text = cp.Location.ToString(); richTextBox1.Text = cp.Information; button1.Text = "修改"; this.Index = Index; }
private void button1_Click(object sender, EventArgs e) { int num; ushort loc; try { loc = ushort.Parse(textBox3.Text); num = int.Parse(textBox2.Text); Componets cp = new Componets(textBox1.Text, comboBox1.Text, comboBox2.Text, num, richTextBox1.Text,loc,Picture); this.Close(); if (inf == 0) { Form1.al.Add(cp); } else { Form1.al.Insert(Index,cp); } } catch { MessageBox.Show("不要输入错误数据"); } }