troubleshooting Question

Listview messed up C#

Avatar of Pit76
Pit76Flag for Belgium asked on
C#
4 Comments1 Solution333 ViewsLast Modified:
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

ASKER CERTIFIED SOLUTION
Pit76

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros