We help IT Professionals succeed at work.
Get Started

Listview messed up C#

Pit76
Pit76 asked
on
330 Views
Last Modified: 2012-05-11
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
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE