|
-
Jun 21st, 2011, 09:23 AM
#1
Thread Starter
Lively Member
[RESOLVED] Listview ColumnHeader Sort Indicator
Hi all,
After a long time searching, I am still facing an issue with my listview column header I am trying to add a sort indicator (a small 16x16 arrow, next to the column title - looks quite good).
- My listview is in Ownerdraw mode for : Items & Subitems for a couple of reasons
- So far, I was letting the system do the job for the header (e.drawdefault = true)
I managed to add very easily the arrow using the e.graphics class, right after the e.drawdefault=true, and it is actually working good.
print01.gif

Code:
(Sub ColumnHeader OwnerDraw)
e.DrawDefault = True
e.Graphics.DrawImage(My.Resources.fleche_v2_16x16, 34, 2, 16, 16)
As you can see, I'm simply using a resource, and am forcing it to 16x16 with a custom location x=34 pixels y=2pixels
My issue comes with the following :
Code:
(Sub ColumnHeader OwnerDraw)
e.DrawDefault = True
e.Graphics.DrawImage(My.Resources.fleche_v2_16x16, (e.Bounds.X + 34), 2, 16, 16)
The arrow wont draw 
Of course the sort indicator will sometime be on the 2nd column etc.. That's why I need to use the column header's bounds.
I can already hear you saying : if you do not owner draw, you can't..
But why is it working with a static location (, 34, 2, 16, 16) ans not starting from another static location (e.bounds.x)  
How can I fix that ? I cant find previous issues similar to that one over the internet.
Points of interest :
- I tryed to load the int value e.bounds.x into a variable before, using that instead of e.bounds.x but it's all the same.
- Using the imagelist is not an option, As you can tell from the screenshot, I am already using images for headers.. the sort indicator is coming as another image
- Using ">" or "<" in the header's text is not an option either........ (sorry pal It does not look good at all..)
- Drawing the header totally in owner draw mode would be an option, but it looks quite hard to do (need to manage the "rounded" header style of the system, the mouse over - small yellow line rounded on the sides in WinXp, the click effect....).
Hope someone can help with that!
Any comments will be much appreciated 
CastAway
-
Jun 21st, 2011, 09:45 AM
#2
Re: Listview ColumnHeader Sort Indicator
i found that it was easier to use Arial font for your listview, then you can use ▲ + ▼ in your columnheader text
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 21st, 2011, 10:29 AM
#3
Thread Starter
Lively Member
Re: Listview ColumnHeader Sort Indicator
Thanks for your input!
I had an idea of doing this kind of trick.. and so I had tryied the following unicode signs before posting the thread:
ChrW(&H2228), ChrW(&H2235), ChrW(&H2207), ChrW(&H2228), ChrW(&H22CE), ChrW(&H23EC), ChrW(&H25BC), ChrW(&H25BC)
which include the one you're suggesting (25BC). The problem is that they do not render well in the header. There are "pixelized", very low quality..
That's why I would like to keep on adding a small resx file..
-
Jun 21st, 2011, 10:33 AM
#4
Re: Listview ColumnHeader Sort Indicator
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 21st, 2011, 11:49 AM
#5
Re: Listview ColumnHeader Sort Indicator
-
Jun 21st, 2011, 03:15 PM
#6
Thread Starter
Lively Member
Re: Listview ColumnHeader Sort Indicator
Oh my!
I'll give it a try.. 
To be honest, I understand what it's doing, but I would never be able to write iton my own.
Because it's in C# (and I'm only developping with VB.net), I'll compile it, add the .dll into a VB project and test the extention from vb code..
I'll post the results afterward.
Thanks!
-
Jun 21st, 2011, 03:20 PM
#7
Re: Listview ColumnHeader Sort Indicator
 Originally Posted by castaway
Oh my!
I'll give it a try..
To be honest, I understand what it's doing, but I would never be able to write iton my own.
Because it's in C# (and I'm only developping with VB.net), I'll compile it, add the .dll into a VB project and test the extention from vb code..
I'll post the results afterward.
Thanks!
No need, just convert the code here.
-
Jun 21st, 2011, 04:04 PM
#8
Thread Starter
Lively Member
Re: Listview ColumnHeader Sort Indicator
By the time of writing back, I managed to compile it under C# / reference it under VB and use it.
It's working ok so far 
I'll now try to convert the c# > vb...... so that I don't have to add a dll just for that purpose. Having it in one class in the project would be neat..
Thank you very much !!!!
-
Jun 21st, 2011, 05:19 PM
#9
Thread Starter
Lively Member
Re: Listview ColumnHeader Sort Indicator
Knowing the API used, I could then find resources for this issue :
TheBitGuru
WinApiZone
ans others..
I could convert the code to Vb.net and it's working well.
I'm now trying to see if I could change the HDF_SORTUP and HDF_SORTDOWN with a custom image =) That way I would be able to insert my resource picture.
But anyway, it's quite tricky so I might as well just use it like it is.. and it's good enough 
Thanks again for your help!
-
Jun 24th, 2011, 07:58 AM
#10
Thread Starter
Lively Member
Re: [RESOLVED] Listview ColumnHeader Sort Indicator
Edit : It works well with _IMAGE instead of _SORTDOWN or _SORTUP
Only problem is that it will remove the other image on the column header 
(if you dont have any image in your column header, then it's all fine, but if you do, like in my project, well it will be either on the left, or on the right as a sort indicator, but not both.
My plan was to leave a column header image on the left, and a small arrow on the right......)
Will need to owner draw the full header :/
That's bad because column header's mouse over event are pretty hard to catch.. dont even know how to do so far......
Anyway, if someone has a clue..
-
Jun 24th, 2011, 09:09 AM
#11
Re: [RESOLVED] Listview ColumnHeader Sort Indicator
 Originally Posted by castaway
Edit : It works well with _IMAGE instead of _SORTDOWN or _SORTUP
Only problem is that it will remove the other image on the column header
(if you dont have any image in your column header, then it's all fine, but if you do, like in my project, well it will be either on the left, or on the right as a sort indicator, but not both.
My plan was to leave a column header image on the left, and a small arrow on the right......)
Will need to owner draw the full header :/
That's bad because column header's mouse over event are pretty hard to catch.. dont even know how to do so far......
Anyway, if someone has a clue..
It would be best to start a new thread if you have a new question.
-
Jun 25th, 2011, 08:20 AM
#12
Thread Starter
Lively Member
Re: [RESOLVED] Listview ColumnHeader Sort Indicator
I actually did 2 days ago 
here
But you're right.. this topic's over
Tags for this Thread
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
|