Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have two listview controls. In the code below I'm copying each item from the left listview to the one on the right side. I have a statusbar showing the number of items in the right listview. It shows the correct number so I think they're getting added, just not painting. Oh yea... the column headings (which have text) show as blank. Any help?

 

       frmMain.lvwLeftList.BeginUpdate()
       For Each SelLeftItem In frmMain.lvwLeftList.Items
           SelLeftItem.ImageIndex = 1
           SelLeftItem.ForeColor = Color.Blue
           Dim SelItem As String = SelLeftItem.Text
           Dim tmpItem As ListViewItem = CType(SelLeftItem.Clone(), ListViewItem)
           frmMain.lvwRightList.Items.Add(tmpItem)
           frmMain.ToolStripStatusRightShown.Text = "Total: " & frmMain.lvwRightList.Items.Count
       Next
       frmMain.lvwLeftList.EndUpdate()

Posted

From what I can tell theres nothing wrong with the code you have posted, the problem could be elsewhere. Do both listviews have the same amount of columns? Are they both set as detailed view?

 

EDIT:- Oops i just noticed your calling BeginUpdate and EndUpdate on the left listview, but as you are adding the items to the right listview its that you should be calling them on.

Anybody looking for a graduate programmer (Midlands, England)?
Posted

Yes, both are set as detail and both have the same number of coulmns. Also, both have sorting set to none. I ran into this periodically with other code in my app but the portion I posted never works.

 

From what I can tell theres nothing wrong with the code you have posted' date=' the problem could be elsewhere. Do both listviews have the same amount of columns? Are they both set as detailed view?[/quote']
Posted

Did some experimenting. If I change the view property to anything except Details it works fine. However I need it set to Details. The other settings don't give me what I'm looking for.

 

From what I can tell theres nothing wrong with the code you have posted, the problem could be elsewhere. Do both listviews have the same amount of columns? Are they both set as detailed view?

 

EDIT:- Oops i just noticed your calling BeginUpdate and EndUpdate on the left listview, but as you are adding the items to the right listview its that you should be calling them on.

Posted

Can anyone help me? Have I found a bug in the control? If so is there a third party control I can use? I really need to be able to set the properties to Details or something similar.

 

Did some experimenting. If I change the view property to anything except Details it works fine. However I need it set to Details. The other settings don't give me what I'm looking for.
Posted

I found a work around. Further up in the code I had a listview.clear method called. I've found that if I remove each item one at a time through a loop the listview paints correctly. I still think it's a bug in the listview control though.

 

Can anyone help me? Have I found a bug in the control? If so is there a third party control I can use? I really need to be able to set the properties to Details or something similar.
  • Leaders
Posted
Here is your problem. There is a big difference between ListView.Clear and ListView.Items.Clear (I found this out the hard way too). ListView.Clear clears all the items, all the columns, and maybe some other properties (I'm not sure). If you are looking to simply remove all items, use ListView.Items.Clear.
[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...