PDA

View Full Version : How to add the value of columns to listview



Nader
02-19-2008, 09:26 AM
How to add the values of 8 columns to listview with the head of each columns.

Bob Phillips
02-19-2008, 10:43 AM
Put the data in a worksheet range, with the headings and set the rowSource property of the listbox to that range but not the headings, set the ColumnCount property to your number of columns, and the ColumnHeads property to True.

Nader
02-22-2008, 04:10 AM
I tried this code but didn't succeed


ListView1.RowSource = Sheets(1).Range("a1:d6")
ListView1.ColumnHeaders = True

By the way there is no columnCount property.

Bob Phillips
02-22-2008, 04:36 AM
Oops I was thinking ListBox not ListView.

Nader
02-22-2008, 09:31 AM
Here is the code for one row in column 1


With ListView1
.View = lvwReport
With .ColumnHeaders
.Clear
.Add , , "First column", 100
End With
.ListItems.Add , , Sheets(1).Range("A1")
End With

how to load all item in the column 1

lifeson
02-22-2008, 01:16 PM
How to add the values of 8 columns to listview with the head of each columns.

Unless the names of the columns are going to change, its much easier to use the columnheaders tool on the listview custom control