Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listview.items.clear() wont clear Damnit

Status
Not open for further replies.

hexOffender

Programmer
Nov 6, 2006
146
0
0
US
The listview is on a tabcontrol. But filling the listview was not that difficult. So why wontlistview1.items.clear() do its damnd job.
 
I've used it several times before in 2.0. So unless you are using 1.1 from what Rick said I would think it would work. What happens when you try? Any error or does it seem to complete without any visible effect?

-I hate Microsoft!
-Forever and always forward.
 
If you put a breakpoint on the line after "wontlistview1.items.Clear()" and run "?wontlistview1.items.Count" in the immediate window, what does it say?

Senior Software Developer
 
I get a item count of zero, could it have something to do with calling this line of code from another form? I would have thought if it couldn't find the listview it would have thrown an exception ie. Object reference not set.... but It runs thgrough the code just fine w/ nary an ex. All I really want to do is clear it so I can rebind it. I think I will just loop through all the items klike rick suggested. Oh, and it is 1.1, because were cheap.
 
If the item count is zero, then it is getting cleared as you want it to, but then getting rebound/reloaded somewhere after that is called.

Are you sure you even have to clear it? Just try setting the new data binding information.


Senior Software Developer
 
You say that you are calling the clear code from another form. Is there a possibility that the listview is getting repopulated when you re-enter the form with the listview?

Step thru your code and see what is happening where and when. It might be helpful.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top