![]() |
Get items in ListView in columns
Using Excel XP.
Does anybody have a simple example of how to get items (short strings) in a ListView control in columns? It has to be added in a loop like this: Add item in column 1 Add item in column 2 Add item in column 3 Add item in column 1 etc. Seems a simple thing, but I can't get it to work. Thanks for any assistance. RBS |
Get items in ListView in columns
Let me be a bit more specific.
This is the relevant code bits to do with the ListView: With ListView1 .HideColumnHeaders = False .HideSelection = False .LabelEdit = lvwManual .Sorted = False .TextBackground = lvwOpaque .FullRowSelect = True .View = lvwReport End With With ListView1 .ListItems.Add i, , hwnd .ListItems(i).ListSubItems.Add , , sClassname .ListItems(i).ListSubItems.Add , , sWindowText End With On testing (msgbox, ListView1.ListItems.Count) all seems to be working fine, but nothing shows in the ListView. I can't even get column header to show, although the grey column shows on the top. I am talking here about the Microsoft ListView Control 6.0 (SP6) in VBA. I am just puzzeled by this and would greatly appreciate any advice. RBS "RB Smissaert" wrote in message ... Using Excel XP. Does anybody have a simple example of how to get items (short strings) in a ListView control in columns? It has to be added in a loop like this: Add item in column 1 Add item in column 2 Add item in column 3 Add item in column 1 etc. Seems a simple thing, but I can't get it to work. Thanks for any assistance. RBS |
Get items in ListView in columns
Still no luck with this.
I replaced the file mscomctl.ocx with a new one, although I had the latest version (6.1.95.45), but it made no difference. Tried all sorts of different syntaxes like: Dim itmX As ListItem Set itmX = ListView1.ListItems.Add itmX.Text = hwnd itmX.ListSubItems.Add , , sClassname itmX.ListSubItems.Add , , sWindowText Still nothing shows in the ListView. Really mysified by this. RBS "RB Smissaert" wrote in message ... Using Excel XP. Does anybody have a simple example of how to get items (short strings) in a ListView control in columns? It has to be added in a loop like this: Add item in column 1 Add item in column 2 Add item in column 3 Add item in column 1 etc. Seems a simple thing, but I can't get it to work. Thanks for any assistance. RBS |
Get items in ListView in columns
Done some testing with a ListView in it's simplest form.
Opened a new workbook. Added a form. Added a ListView, called ListView1 Added a code module with the following code: Sub LoadUserForm() Load UserForm1 UserForm1.Show With UserForm1.ListView1 .View = lvwReport .Appearance = ccFlat .Enabled = True .FullRowSelect = False .Gridlines = True .HideSelection = False .LabelEdit = lvwManual End With Dim itmX As ListItem Set itmX = UserForm1.ListView1.ListItems.Add itmX.Text = "item1" itmX.ListSubItems.Add , , "item2" itmX.ListSubItems.Add , , "item3" End Sub Now sometimes this shows item1 and sometimes no items. Item 2 and 3 never show. Clearly something is corrupted here. Think I might have to reinstall Excel. RBS "RB Smissaert" wrote in message ... Using Excel XP. Does anybody have a simple example of how to get items (short strings) in a ListView control in columns? It has to be added in a loop like this: Add item in column 1 Add item in column 2 Add item in column 3 Add item in column 1 etc. Seems a simple thing, but I can't get it to work. Thanks for any assistance. RBS |
All times are GMT +1. The time now is 03:07 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com