|
-
Jun 26th, 2007, 10:41 AM
#1
Thread Starter
Frenzied Member
Show selected Column (Listview)
I have a listview with approx 20 columns, 4 of which are dates.
When I scroll along to one of these dates columns, and click on the columnheader to sort that column, I clear the listbox and reload in the sort order by recalling the data from the database via a recordset.
The problem is, although the data is sorted as I want, the column that has the sort on it is now not showing. I have to scroll back along to show it.
How can I set it so that the column that has the sort on it is visible?
I looked for an 'EnsureVisible' property, but either I have missed it somehow, or that isn't the way to go.
-
Jun 26th, 2007, 11:42 AM
#2
Re: Show selected Column (Listview)
aikido..
What about a Refresh?
ListView1.refresh
since you have sorted the DB, records may reloaed in the latest order in to the list view
-
Jun 27th, 2007, 08:13 AM
#3
Thread Starter
Frenzied Member
Re: Show selected Column (Listview)
No, this doesn't work Fazi. It is still sorted, but the sorted column still doesn't show without scrolling to it!
-
Jun 27th, 2007, 08:25 AM
#4
Re: Show selected Column (Listview)
How about using the Position Property to move the column to the first position:
VB Code:
Private Sub Command1_Click()
ListView1.ColumnHeaders.Item(3).Position = 1
End Sub
Regards,
Mark
Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."
-
Jun 27th, 2007, 08:29 AM
#5
Thread Starter
Frenzied Member
Re: Show selected Column (Listview)
I would like to try to keep all of the columns in the same place as they work across in a specific order, which is relevent else where.
-
Jun 27th, 2007, 08:30 AM
#6
Re: Show selected Column (Listview)
 Originally Posted by aikidokid
I would like to try to keep all of the columns in the same place as they work across in a specific order, which is relevent else where.
Hmm, I am not sure how you could do then, sorry
Regards,
Mark
Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."
-
Jun 27th, 2007, 08:32 AM
#7
Thread Starter
Frenzied Member
Re: Show selected Column (Listview)
Ok, thanks anyway Mark and Fazi, I will keep looking
-
Jun 27th, 2007, 09:13 AM
#8
Thread Starter
Frenzied Member
Re: Show selected Column (Listview)
I have been looking at MSDN here and more specifically here
I have tried using this but I get the error message:
Run-time-error '438': Property doesn't support this method
Code:
lresult = SendMessage(lvwShowAll, LVM_SETSELECTEDCOLUMN, 12, 0)
I just wondered what I have wrong with this code, and secondly, is this something that would achieve what I am after?
-
Jun 27th, 2007, 09:24 AM
#9
Re: Show selected Column (Listview)
Is lvwShowAll a control or the hWnd of a control? (I don't think the default property of a listview is its hWnd.) SendMessage wants an hWnd as the first parameter.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
-
Jun 27th, 2007, 09:29 AM
#10
Thread Starter
Frenzied Member
Re: Show selected Column (Listview)
 Originally Posted by Al42
Is lvwShowAll a control or the hWnd of a control? (I don't think the default property of a listview is its hWnd.) SendMessage wants an hWnd as the first parameter.
OOPS, that was a bit obvious
I have tried this and it runs, but either I don't know how to correctly use it or it doesn't do what I am after, which is to make sure a ceretain column is showing after reloading the listview from a recordset, loaded by date order.
Any ideas?
-
Jun 27th, 2007, 10:47 AM
#11
Re: Show selected Column (Listview)
akido,
check this link as well. http://vbnet.mvps.org/code/comctl/lvmembers.htm
it has tons of messages that you can send to a listview .
-
Jun 27th, 2007, 12:36 PM
#12
Thread Starter
Frenzied Member
Re: Show selected Column (Listview)
Thanks Fazi. I have bookmarked that site 
I have changed my code to
Code:
SendMessage lvwShowAll.hWnd, LVM_SETSELECTEDCOLUMN, ColumnHeader.Index - 1, 0
but this still does not work..
From what I have read and found out so far, this is the message I need, so am I using it incorrectly?
 Originally Posted by Microsoft Forum
How does the ListView know which column is used for sorting?
LVM_SETSELECTEDCOLUMN
Last edited by aikidokid; Jun 28th, 2007 at 10:43 AM.
-
Jun 27th, 2007, 12:40 PM
#13
Thread Starter
Frenzied Member
Re: Show selected Column (Listview)
I now have this, but LVM_SETSELECTEDCOLUMN is showing a value of "Empty" and I don't know why!
vb Code:
If ColumnHeader.Index - 1 = 12 Then
SendMessage lvwShowAll.hWnd, LVM_SETSELECTEDCOLUMN, ColumnHeader.Index - 1, 0
End If
-
Jun 27th, 2007, 01:31 PM
#14
Re: Show selected Column (Listview)
Any thig to do with the below
LVM_SETSELECTEDCOLUMN Message
MSDN :
Note: To use this API, you must provide a manifest specifying Comclt32.dll version 6.0.
-
Jun 27th, 2007, 01:40 PM
#15
Thread Starter
Frenzied Member
Re: Show selected Column (Listview)
Thanks Fazi, I have actually been looking at this here.
I have to be honest, this seems a bit too advanced for me.
I have never used manifest files.
I don't have a lot of experience using 'SendMessage' apart from code that people have helped me with!
-
Jun 27th, 2007, 01:47 PM
#16
Re: Show selected Column (Listview)
to apply XP visual style to listviews, you need to use microsoft windows common controlls 5.0 sp2. then applying XP style is very simple. tons of articles and manifiest files are on the net.
dont warry.
-
Jun 27th, 2007, 01:54 PM
#17
Thread Starter
Frenzied Member
Re: Show selected Column (Listview)
What is the difference between Windows common controls 5.0 SP2
and what I am using which is Windows common controls 6.0 SP6
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
|
Click Here to Expand Forum to Full Width
|