Listview messed up C#

Pit76 used Ask the Experts™
Hi all,

I have a background worker process that gets data from the db and after some manipulations it adds the data to a List<>.
In the RunWorkerCompleted Event I try to load that List<> into my Listview, but here is the problem.
My listview is messed up. My columns disappear and no data is filled.

You can see the code I have in the RunWorkerCompleted Event.

In the scrrenshot you can see the result in the listview, it should normaly contains 7 rows with 2 columns.. The list is not empty, so that isn't the problem. What happens here?? I also added a screenshot of the listview at start up, which is ok.
I can't figure it out. Thx for any help.
 listview_messed up listview at program start, ok
private void backgroundWorkerSearch_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
      toolStripStatusLabelProgress.Text = "Done!!";
      labelResults.Text = string.Format("Found {0} matches.", _contentList.Count);


      foreach (var contentValue in _contentList)
        item = new ListViewItem();
        item.Text = contentValue.guid;

Open in new window

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Try listViewResults.Items.Clear() instead of listViewResults.Clear()
I found my error:

listViewResults.Clear(); this was wrong, it had to be listViewResults.Items.Clear();
Now everything works fine. Stupid mistake :)


I did found it myself but it seems morgulo has answered the correct answer when I was trying myself.
Is it possible to allow him the points


I found it myself...

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial