bjwade62 Posted February 14, 2006 Posted February 14, 2006 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() Quote
Cags Posted February 14, 2006 Posted February 14, 2006 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. Quote Anybody looking for a graduate programmer (Midlands, England)?
bjwade62 Posted February 14, 2006 Author Posted February 14, 2006 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'] Quote
bjwade62 Posted February 14, 2006 Author Posted February 14, 2006 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. Quote
bjwade62 Posted February 14, 2006 Author Posted February 14, 2006 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. Quote
bjwade62 Posted February 14, 2006 Author Posted February 14, 2006 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. Quote
Leaders snarfblam Posted February 15, 2006 Leaders Posted February 15, 2006 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. Quote [sIGPIC]e[/sIGPIC]
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.