-
VB6 using a ListView control
I am putting information in a list view control using the listItems.add and that works fine however I would like to put the information in the list in reverse order, so that the first item is at the bottom of the list view and the last item is at the top. Can that be done durring the loading of the list or must the information be re-aranged prior to loading the list view ???
-
From what are you loading the listview?
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
-
I am just using a variable, I put the data in variable "a", "b", "c, etc then
With LVMem
.ListItems.Add , , a 'put the value in the List box column 1
With .ListItems(LVMem.ListItems.Count)
.SubItems(1) = b 'put the value in the List box col 2, column 2
.SubItems(2) = c 'put the value in the List box col 3
.SubItems(3) = d 'put the value in the List box col 4
.SubItems(4) = e 'put the value in the List box col 5
.SubItems(5) = F 'put the value in the List box col 6
.SubItems(6) = g 'put the value in the List box col 7
.SubItems(7) = h 'put the value in the List box col 7
End With
End With
-
If you are hard coding it, then the only manipulation available to you would be to hard code it in whatever order you want.
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
-
Not what I wanted to hear, but looks like the only way. Thanks for the help.
-
If you wanted it to be available in both ascending and descending order, or some other kinds of orders, you could set each hard coded order up in a separate sub routine and call the appropriate one based on some kind of user selected.
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
-
You could always just sort after entry. Which view are you using in the listview? In the Report view, you can add code that sorts the data when a column header is clicked.
-
that sounds interesting. Would that sort just that one column or sort all accordingly ?
-
It works just like an explorer window. If you select the detail view and then click the Type column, it sorts the files according to type.
-
That sounds like an easy way, is there an example someplace ?
-
try this for sorting a listview
Code:
Private Sub ListView1_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
ListView1.SortKey = ColumnHeader.Index - 1
ListView1.Sorted = True
' toggle the sort order between ascending & descending
ListView1.SortOrder = 1 Xor ListView1.SortOrder
End Sub
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
-
I'll give it a try, thanks
-
It simply toggles the sort between ascending and descending.
I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
Please use [Code]your code goes in here[/Code] tags when posting code.
Before posting your question, did you look here?
Got a question on Linux? Visit our Linux sister site.
Modifications Required For VB6 Apps To Work On Vista
-
This is what I use.
Code:
Private Sub lvw_ColumnClick(ByVal ColumnHeader As ColumnHeader)
' sort the listview on the column clicked
With lvw
If (.Sorted) And (ColumnHeader.SubItemIndex = .SortKey) Then
If .SortOrder = lvwAscending Then
.SortOrder = lvwDescending
Else
.SortOrder = lvwAscending
End If
Else
.Sorted = True
.SortKey = ColumnHeader.SubItemIndex
.SortOrder = lvwAscending
End If
.Refresh
End With
' If an item was selected prior to the sort,
' make sure it is still visible now that the sort is done.
If Not lvw.SelectedItem Is Nothing Then
lvw.SelectedItem.EnsureVisible
End If
End Sub
When you click the column header the _ColumnClick event fires.
When the column is clicked, if the column hasn't been sorted previously, it sorts ascending, otherwise it reverses the sort order.
In the code, be sure that "lvw" is replaced with your listview name.
-
OK, I've got the code in, I have it set up so that I call this sub from another sub, a simple Call but need a little help, in the part:
Private Sub lvw_ColumnClick(ByVal ColumnHeader As ColumnHeader)
what do I pass as the ColumnHeader ? is that the column number or column name or what??? Example: call lvw_ColumnClick(????I don't know what to put here???)
Similar Threads
-
By badascan in forum VB Classic
Replies: 1
Last Post: 06-05-2007, 10:52 AM
-
By Mike Kraemer in forum VB Classic
Replies: 3
Last Post: 06-13-2002, 09:21 AM
-
By Mike Kraemer in forum VB Classic
Replies: 1
Last Post: 05-29-2002, 06:36 PM
-
By Birhanu in forum VB Classic
Replies: 0
Last Post: 11-09-2001, 03:26 PM
-
By shachar in forum VB Classic
Replies: 0
Last Post: 07-12-2001, 04:41 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks