
-----------------------------------
GlobeTrotter
Mon Mar 28, 2005 3:57 pm

Lists With Columns
-----------------------------------
Is it possible to create a type of list with multiple columns, that can be dragged around, and stretched, and also sorted based on which title/top row you click on.  Similar to this picture, taken from the task manager.

-----------------------------------
Brightguy
Tue Mar 29, 2005 2:30 pm

Re: Lists With Columns
-----------------------------------
Personally I've never used it, but you can do that with the [url=http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cmctl198/html/vbobjlistview.asp]ListView control in report view.  (To use the control, add the component "Microsoft Windows Common Controls" into your project.)

I tried it out for a minute and got a test working.  Although you have to write the sorting procedure yourself, in the ColumnClick event.

-----------------------------------
GlobeTrotter
Tue Mar 29, 2005 5:03 pm


-----------------------------------
I can't seem to make it more than one column, or have the button at the top with the column title.

I tried this to add a column, but it didn't work.

lvTracks.ColumnHeaders.Add = "Test"


How did you get it working?

-----------------------------------
Brightguy
Wed Mar 30, 2005 6:57 pm

Re: Lists With Columns
-----------------------------------
First you have to change the view property to lvwReport.

A lot of design time properties can be set in the "Custom" window.  There actually is an option to automatically sort the items.  (Which I overlooked.)

-----------------------------------
GlobeTrotter
Sun May 15, 2005 10:36 pm


-----------------------------------
Okay, I've got a couple of problems.  First of all, I can only deal with the first column.  I can't seem to add to the other columns, or edit them because I don't know how.  For example, if I just put lVW.ListItems.Add = "1" It will add a 1 to the first row/column, but how do I do the 2nd.  My other question, I realized how to sort the things, but why won't this code work?

Private Sub lvwTracks_ColumnClick(ByVal ColumnHeader As ComctlLib.ColumnHeader)
    lvwTracks.SortKey = ColumnHeader.Key
    If lvwTracks.SortOrder = lvwAscending Then
        lvwTracks.SortOrder = lvwDescending
    Else
        lvwTracks.SortOrder = lvlAscending
    End If
End Sub

-----------------------------------
Brightguy
Thu May 19, 2005 1:26 pm

Re: Lists With Columns
-----------------------------------
Try this:
lvwTracks.ListItems.Add.SubItems(1) = "2nd column"
And:
lvwTracks.SortKey = ColumnHeader.Index - 1

-----------------------------------
GlobeTrotter
Thu May 19, 2005 5:05 pm


-----------------------------------
Thanks.
