How to delete item from listbox at particular location in C#

Go To StackoverFlow.com

0

How can I delete an item from listbox at particular location and not the SELECTED one?

Let's say if I have 4 items in listbox and I want to delete the one at index 2, how can I do that without selecting it.

2012-04-04 07:23
by Ali
which platform? ASP.NET Silverlight Winform - Shoaib Shaikh 2012-04-04 07:24
No it's desktop application - Ali 2012-04-04 07:26
In that case: WPF or Windows Forms - Joey 2012-04-04 07:26


3

ListBox.Items should be a List. More precise a ListBox.ObjectCollection

Have you tried :

myListBox.Items.RemoveAt(2);

RemoveAt refference in MSDN

2012-04-04 07:26
by Tarion
Added some links to MSD - Tarion 2012-04-04 07:39


1

listBox1.Items.RemoveAt(position);
2012-04-04 07:25
by ionden


1

ListBox1.Items.RemoveAt(anyindex);
2012-04-04 07:28
by Ali Issa
Ads