C#中listbox中选中多项,并删除

1.SelectionMode 改成可以多选
2.利用KeyDown事件:
private void listBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete)
{
for (int i = listBox1.SelectedItems.Count - 1; i > -1; i--)
{
listBox1.Items.Remove(listBox1.SelectedItems[i]);
}
}
}

posted on 2014-07-13 18:16  浪月悠虫  阅读(1840)  评论(0编辑  收藏  举报

导航