// how to know which text you choice or edit private void button1_Click(object sender, System.EventArgs e) { int FindIndex; string strMsg = "目前你的选择是:"; FindIndex = MulQuery.FindStringExact(MulQuery.Text); if (FindIndex < 0) { MulQuery.Items.Add(MulQuery.Text); strMsg += MulQuery.Text; } else { strMsg += MulQuery.SelectedItem.ToString(); } MessageBox.Show(strMsg); }
//Part 2: ComboBox Test //How to add string to the combobox private void button2_Click(object sender, System.EventArgs e) { if (MulQuery.FindString("有教授参与授课的所有课程") < 0) { MulQuery.BeginUpdate(); MulQuery.Items.Add("有教授参与授课的所有课程"); MulQuery.Items.Add("有副教授参与授课的所有课程"); MulQuery.Items.Add("所有选择教授所授课程的学生"); MulQuery.Items.Add("王心怡老师的所有学生"); MulQuery.Items.Add("所有有课程冲突的学生"); MulQuery.EndUpdate(); } if (MulQuery.FindString(MulQuery.Text) < 0) { MulQuery.BeginUpdate(); MulQuery.Items.Add(MulQuery.Text); MulQuery.EndUpdate(); } else { MessageBox.Show(MulQuery.Text + "已经存在"); } }