"Morten Wennevik" wrote:
Hi mostafa atalla,
ListBox.SelectedObjectCollection s = listBox1.SelectedItems;
while(s.Count > 0)
listBox1.Items.Remove(s[0]);
The SelectedObjectCollection is directly tied to the listbox items and when you remove an item, the item is also gone from the collection.
--
Happy coding!
Morten Wennevik [C# MVP]
Dear sir :
when I wrote the previous code and run , the following exception appeared :
An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll
Additional information: Cannot modify the Items collection when the DataSource property is set.
the DataSource property must be set to the database,what can i do to solve this problem??