Suppose ListBox1 be the list box with some items in it we can delete the selected items in the Listbox with the below code..
for Multiple selection, enable the Multiple option of the List box to "Multiple"..
for (int i = 0; i < ListBox1.Items.Count; i++)
{
int myindx = ListBox1.SelectedIndex;
if (myindx >= 0)
{
if (ListBox1.Items[myindx].Selected == true)
{
ListBox1.Items.RemoveAt(myindx);
}
}
}
let know it helped u...
ReplyDeleteyea its working ...
ReplyDeleteall left listbox items are removing by this way..
thanx yaar
This comment has been removed by the author.
ReplyDeleteThank u ...
ReplyDeleteWhy can'e we use foreach loop instead of for loop?
ReplyDeleteforeach has better performance I think...
looping take an amount of system time whether for or foreach
ReplyDelete