I try the foll. code---
protected void Button1_Click(object sender, EventArgs e)
{
int i;
for (i = 0; i <= ListBox1.Items.Count - 1; i++)
{
ListBox1.Items.Remove(ListBox1.SelectedValue.ToString());
}
}
But it's not working.
I try the foll. code---
protected void Button1_Click(object sender, EventArgs e)
{
int i;
for (i = 0; i <= ListBox1.Items.Count - 1; i++)
{
ListBox1.Items.Remove(ListBox1.SelectedValue.ToString());
}
}
But it's not working.
Or you can try this, but this following code not working in .net 1.1 :
public void RemoveItem()
{
for (int i = 0; i < listBox1.Items.Count; i++)
{
if (listBox1.Items[i].Selected)
{
listBox1.Items[i].Selected = false;
listBox1.Items.RemoveAt(i);
RemoveItem();
}
}
}
Also u can try this foll code too :
while (listBox1.SelectedItems.Count > 0)
{
listBox1.Items.Remove(listBox1.SelectedItems[0]);
}
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.