this was driving me mad, so I just have to write a post in the hope that someone will find it and not have to go through the head scratching I've experienced tonight.
I've been working on a utility for managing Metalogix batch files. these files store migration and copy operations from one SharePoint server to another.
as part of this app, I'm using a .NET ListView control to show the files. the control worked fine the first time I loaded data, but after it had been cleared once, it wouldn't work again. the ListView control showed nothing--no data, no columns, nothing...
it was actually the lack of columns that led me to the solution. it turns out that I had been a bit sloppy and used: ListView.Clear(); instead of ListView.Items.Clear();.
the ListView.Clear() method clears everything from the control--including the columns that I had created to hold my data. this isn't what I wanted. I meant to clear the items in the control. after doing this, I messed up the columns so that even though I was adding items with
ListView.Items.Add(ListItem), the control wouldn't show anything.
some tell-tale signs of this issue were that the ListView.Items.Count was not zero, but the control didn't display anything.
to help people find this, I'm going to add some text below.
ListView empty
ListView shows nothing
ListView displays nothing
ListView problem
ListView.Items.Add problem
ListView has no columns
ListView.Clear() removes columns
Friday, June 13, 2008
Subscribe to:
Post Comments (Atom)
29 comments:
THANK YOU! I found your post after looking for a solution, which I am not sure I would have found too easily!
Thanks, I was having the same issue and found your post.
Cheers
Barry McDermid
Dude, that saved me. Thanks for posting!
thanks!
i can't believe i overlooked that.
what a dope!
Same as all the others. Thanks
Oh man! Thanks!
I've over a decade programming with Microsoft VB6, VB.NET, C# - Web and Windows and other non-M$ apps.
Sure as snot, I'd intorduced this into one of my application builds this week and today couldn't figure out for the life of me what it was until I read this post.
Thank you.
Your post was just what I needed. Thank you so much!
Thanks. You just saved me some much needed time.
thank you!
Your the best.
Thank you, this really helped me out!
thank you very much for this post, it just cured my headache :)
Thanks! "I don't remember it being this hard...." =)
Thanks, nice post. I hadn't realised that I would need to add a column myself before using the control...
Thank you so much, it was driving me mad
Thank you very much for this, it was a clever catch.
Like the others -- thanks!
You may also check the OwnerDraw setting of the listview. If its True, no items will appear unless you code alle the Draw events yourself.
Thanks so much! Your post helped me. I was loosing my nerves...
OMG!!!!
I've been searching the web for at least 2 hours. I thought I was going mad!!
Thank you very very very much.
I haven't used the Clear() anywhere... My ListView control just goes blank whenever I add Items to it, for the first time and for every time I do this... Help me!
Thanks :) this was really starting to annoy me!
thanks a lot for pointing me out to the source of the problem.
OH MY GOSH!!!!!! It was driving me insane.
OH MY GOSH!!!!! That was driving me insane.
Thank you. I was at a loss.
Thanks a bunch!
Glad I found this so quickly after a search, probably saved me hours lol.
Thank you so very much for sharing. This saved me a lot of time and aggrevation.
Post a Comment