private void button2_Click(object sender, EventArgs e) { SqListClass L4 = new SqListClass(); Merge3(ref L4); textBox4.Text = L4.DispList(); }
private void comboBox1_SelectedIndexChanged_1(object sender, EventArgs e) { int k = comboBox1.SelectedIndex; //使用combobox中的索引号来判断要执行什么操作 if (k == 0) { textBox2.Enabled = false; label3.Text = "长度"; textBox3.Text = L.ListLength().ToString(); } else if (k == 1) { textBox2.Enabled = true; label3.Text = "序号"; label4.Text = "元素"; Findele(); } else if (k == 2) { textBox2.Enabled = true; label3.Text = "元素"; label4.Text = "序号"; Findnum(); } else if (k == 3) { textBox2.Enabled = true; label3.Text = "序号"; label4.Text = "元素"; Insert(); } else if (k == 4) { textBox2.Enabled = true; string text3 = textBox3.Text.ToString(); string text2 = textBox2.Text.ToString(); label3.Text = "按序号"; label4.Text = "按元素"; if (text3 != "" && text2 == "") { Deletebynum(); } else if (text3 == "" && text2 != "") { Deletebyele(text2); } } else if (k == 5) { textBox2.Enabled = true; SqListClass L1 = new SqListClass(); SqListClass L2 = new SqListClass(); Split(ref L1, ref L2); label3.Text = "奇数序号的元素"; label4.Text = "偶数序号的元素"; textBox3.Text = L1.DispList(); textBox2.Text = L2.DispList(); } }
private void Insert() //插入元素 { int i; string x, str; if (textBox3.Text.Trim() == "") { label2.Text = "必须输入序号"; } else { try { i = Convert.ToInt16(textBox3.Text.Trim()); } catch (Exception err) { label2.Text = "输入的序号是错误的"; return; } x = textBox2.Text.Trim(); if (x == "") { label2.Text = "操作提示:必须输入元素值"; } else { if (L.ListInsert(i, x)) { str = L.DispList(); textBox4.Text = str; label2.Text = "操作提示:成功插入元素" + x; } else { label2.Text = "操作提示:输入的序号" + i.ToString() + "错误"; textBox4.Text = ""; } } } }