Listview messed up C#

Pit76
Pit76 used Ask the Experts™
on
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)
    {
      Thread.Sleep(1000);
      toolStripStatusLabelProgress.Text = "Done!!";
      labelResults.Text = string.Format("Found {0} matches.", _contentList.Count);

      listViewResults.Clear();

      foreach (var contentValue in _contentList)
      {
        item = new ListViewItem();
        item.Text = contentValue.guid;
        item.SubItems.Add(contentValue.contentValue);
        listViewResults.Items.Add(item);
      }
      
    }

Open in new window

Comment
Watch Question

Do more with

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

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

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

Author

Commented:
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

Author

Commented:
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