Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Lists With Columns
Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
GlobeTrotter




PostPosted: Mon Mar 28, 2005 3:57 pm   Post subject: 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.


List With Columns.bmp
 Description:
 Filesize:  296.19 KB
 Viewed:  3319 Time(s)

List With Columns.bmp



List With Columns.bmp
 Description:
Picture of what I want to make in VB
 Filesize:  296.19 KB
 Viewed:  3316 Time(s)

List With Columns.bmp


Sponsor
Sponsor
Sponsor
sponsor
Brightguy




PostPosted: Tue Mar 29, 2005 2:30 pm   Post subject: Re: Lists With Columns

Personally I've never used it, but you can do that with the 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




PostPosted: Tue Mar 29, 2005 5:03 pm   Post subject: (No subject)

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.
code:

lvTracks.ColumnHeaders.Add = "Test"


How did you get it working?
Brightguy




PostPosted: Wed Mar 30, 2005 6:57 pm   Post subject: 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




PostPosted: Sun May 15, 2005 10:36 pm   Post subject: (No subject)

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?

code:
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




PostPosted: Thu May 19, 2005 1:26 pm   Post subject: Re: Lists With Columns

Try this:
VisualBASIC:
lvwTracks.ListItems.Add.SubItems(1) = "2nd column"

And:
VisualBASIC:
lvwTracks.SortKey = ColumnHeader.Index - 1
GlobeTrotter




PostPosted: Thu May 19, 2005 5:05 pm   Post subject: (No subject)

Thanks.
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: