If I have two columns, how can I add something to the listview in the following way:
HYKWIM (I use the report style of the ListView)Code:COLUMN1 COLUMN2 '//<---------Column Headers
TEXT1 TEXT2
TEXT3 TEXT4
Printable View
If I have two columns, how can I add something to the listview in the following way:
HYKWIM (I use the report style of the ListView)Code:COLUMN1 COLUMN2 '//<---------Column Headers
TEXT1 TEXT2
TEXT3 TEXT4
How about:
Code:Dim lstItem As ListItem
With ListView1
.ColumnHeaders.Add , "Column1", "Column1"
.ColumnHeaders.Add , "Column2", "Column2"
Set lstItem = .ListItems.Add(1, "Text1", "Text1")
lstItem.SubItems(.ColumnHeaders("Column2").SubItemIndex) = "Text2"
Set lstItem = .ListItems.Add(2, "Text3", "Text3")
lstItem.SubItems(.ColumnHeaders("Column2").SubItemIndex) = "Text4"
Set lstItem = Nothing
End With
Thanks QWERTY. It works fine for adding new items. But there is a problem. I can't select anything what is under the column2. I can select any item from column1, but when I click on "Text2" or "Text4" it doesn't get selected. How to change it? Thanks in advance.