Clearing a listbox

madi2999

Member
Joined
Aug 8, 2004
Messages
10
Programming Experience
Beginner
hello,

I am having a hard time trying to clear a listbox that its datasource is set

lstappl.DataSource = ds.Tables("application")

I tried using lstappl.items.clear but I get this error message

"""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."""""""

I even tried to assigned lstappl.Datasource=Nothing
and then try to excute the clear commend , The above line causes it to disappear but nothing gets cleared up





 
Instead of clearing the listBox, clear the dataSource to which you have bound the listBox. For example:
VB.NET:
ds.Tables("application").Clear
 
Back
Top