listBox1.Items.Add("第一个");
MessageBox.Show("共有" + listBox1.Items.Count);
//选择的项的索引,未选择返回-1
MessageBox.Show(listBox1.SelectedIndex.ToString());
//选择的项的内容,未选择出错
MessageBox.Show(listBox1.SelectedItem.ToString());
//移除指定对象,如果存在多个同样的,从上往下,每次一个
listBox1.Items.Remove("序号5");
//移除指定索引项
listBox1.Items.RemoveAt(2);
listBox1.Items.Clear;
listBox1.Items.Insert;
//返回列表框中指定字符串开头的第一个项
MessageBox.Show(listBox1.FindString("序号1").ToString());
//选择或者清除列表框中指定项的选择
listBox1.SetSelected(1, true);
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。