[英]listbox and how to perform actions on selected items
Hi I have this program Im trying to make 嗨,我有这个程序,我试图
but now Im trying to add an option to delete items ( only the selected ones ). 但是现在我试图添加一个选项来删除项目(仅选定的项目)。
thanx in advance 预先感谢
To delete the selected items: 删除所选项目:
while (listBox1.SelectedIndices.Count > 0)
listBox1.Items.RemoveAt(listBox1.SelectedIndices[0]);
protected void Button2_Click(object sender, EventArgs e)
{
for(int i = ListBox1.Items.Count -1; i>=0; i--)
{
if (ListBox1.Items[i].Selected)
{
ListBox1.Items.Remove(ListBox1.Items[i]);
}
}
}
This should work for deleting also 这也应该删除
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.