------解决方案-------------------- 首先listBox1.Sorted = true; 然后循环 比较当前这个是不是和下一个一样,一样的话就remove object o = listBox1.Items[0]; for (int i = 1; i < listBox1.Items.Count; i++) { if (o.Equals(listBox1[i])) listBox1.Items.Remove(i); else o = listBox1.Items[i];
}
------解决方案--------------------
------解决方案-------------------- 1楼的正解~
------解决方案-------------------- private void Deleted(object obj) { System .Collections .ArrayList list=new System.Collections.ArrayList (); list .Add (((ListBox )obj).Items [0]); for (int i = 1; i < listBox1.Items.Count; i++) { if (list.Contains(listBox1.Items[i])) continue; else list.Add(listBox1.Items[i]); }
listBox1.DataSource = list;
}
------解决方案-------------------- Deleted(this.listBox1); private void Deleted(object obj) { System .Collections .ArrayList list=new System.Collections.ArrayList (); list .Add (((ListBox )obj).Items [0]); for (int i = 1; i < listBox1.Items.Count; i++) { if (list.Contains(listBox1.Items[i])) continue; else list.Add(listBox1.Items[i]); }