Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Controls / November 2007

Tip: Looking for answers? Try searching our database.

Sort Arrows in ListView Control in .NET 2.0

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ricd - 05 May 2006 17:05 GMT
Is there any way to use the HDF_SORTUP and HDF_SORTDOWN format styles in the
current version of the ListView control.  It seems like this has gone away as
the header image list got subsumed by the ListView image list (which I think
means that the solution described in KB 314933 no longer works).  I'd like to
show column sort arrows just to the right of the column header text.
"Jeffrey Tan[MSFT]" - 08 May 2006 07:54 GMT
Hi ricccle65,

Thanks for your post!

No, we can not do this. As we can see in the link below, there is a
statement for HDF_SORTDOWN and HDF_SORTUP flags, "This flag cannot be
combined with HDF_IMAGE or HDF_BITMAP.":
http://msdn.microsoft.com/library/en-us/shellcc/platform/commctls/header/str
uctures/hditem.asp?frame=true

Hope this helps

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
ricd - 08 May 2006 14:53 GMT
Jeffrey, Thanks for your reply.  

With regard to not using HDF_BITMAP or HDF_IMAGE - As the document you
referenced suggests, without supplying an HDF_IMAGE or HDF_BITMAP, we should
be able to set HDF_SORTUP or HDF_SORTDOWN and have the control draw a small
sort direction arrow.  The nice thing about this is that hopefully the arrow
is drawn just to the right of the header column text. This does not seem to
work.

With regard to trying to using the list control's image list and setting
HDF_BITMAP_ON_RIGHT - As you probably have seen, when we do use the list
control's image list to provide our own sort arrow bitmaps, there is no way
to apply the old HDF_BITMAP_ON_RIGHT style.  As soon as I use SendMessage to
set it, the list control takes it away.

With regard to setting the header image list manually - What's more, when I
use the technique suggested in the KB 314933 article, as soon as I set the
header image list, the list control resets that (takes it away) too.

> Hi ricccle65,
>
[quoted text clipped - 16 lines]
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
"Jeffrey Tan[MSFT]" - 09 May 2006 04:55 GMT
Hi ricccle65,

Thanks for your feedback.

I do not think I understand your reply completely.

1. I have tested this scenario in VS2005, and I can assign an ImageList
item to the header control of ListView
2. I think when we are displaying an image on the header control, it should
have HDF_BITMAP flag on, so we should not use HDF_SORTUP or HDF_SORTDOWN.

Can you be a little clear regarding your problem? Thanks

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
ricd - 09 May 2006 14:43 GMT
Sorry for taking so long to be clear about this.  I am suspecting that with
the current structure that wraps the header control so completely within the
ListView, drawing sorting arrows is a completely manual operation (via owner
draw).

Here is the clarification you asked for: I need to display sort arrows to
the right of the header column text in a ListView in Details mode (the 'to
the right' is the important part). I do not need a bitmap for any other
purpose.  I have implemented a test where I am assigning an ImageList
containing up and down arrow bitmaps  to the ListView and this does not work
as desired.  When the ImageList is used to display the arrow, the arrow
always appears to the left of the column header text. I need it to appear on
the right of the text.

I noticed that you said you assigned an ImageList to the header control of
a ListView.  In .NET 2.0, I can only seem to assign an ImageList to the
parent ListView (in .NET 2.0, the header column ImageIndex is an index into
the ListView's ImageList).  Whenever I try to assign an ImageList directly to
the header control, using the technique described in KB 314933, the parent
ListView immediately removes it.

> Hi ricccle65,
>
[quoted text clipped - 17 lines]
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
"Jeffrey Tan[MSFT]" - 11 May 2006 08:08 GMT
Hi ricccle65,

Thanks for your feedback!

Oh, yes. It seems that this is a known issue of ListView control. .Net
winform ListView control does not implement HDF_SORTUP/HDF_SORTDOWN
function. Please refer to the link below:
"Bug Details: ColumnHeader class contains an incomplete implementation of
the class in comctl32"
http://lab.msdn.microsoft.com/ProductFeedback/viewFeedback.aspx?feedbackid=4
1773165-e7f0-47c0-aa06-8f5675684be1

Hope this helps

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
whitey75 - 28 Nov 2007 21:08 GMT
I have found that the way to get the HDF_SORTUP / HDF_SORTDOWN native sort arrows to work is by including a .manifest file within your project.

Just create a text file labeled [appname].manifest (where appname is the name of your resulting excecutable e.g. MyApp.exe.manifest). Then cut and paste the following into it (again substituting [appname] as before).  The curly braces will also need to be substituted for "less than" "greater than" braces (I had to make them into curly braces so that my post isn't mistaken for a Cross-Site Scripting attempt).

{?xml version="1.0" encoding="UTF-8" standalone="yes"?}
{assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"}
{assemblyIdentity
   version="1.0.0.0"
   processorArchitecture="X86"
   name="Microsoft.Windows.[appname]"
   type="win32"
/}
{description}Your app description here{/description}
{dependency}
   {dependentAssembly}
       {assemblyIdentity
           type="win32"
           name="Microsoft.Windows.Common-Controls"
           version="6.0.0.0"
           processorArchitecture="X86"
           publicKeyToken="6595b64144ccf1df"
           language="*"
       /}
   {/dependentAssembly}
{/dependency}
{/assembly}

Then save this file into the directory where your solution file is.

To link this file to your project follow the guide on this link

http://blogs.msdn.com/cheller/archive/2006/08/24/718757.aspx

for more info on .manifest files see this link

http://blogs.msdn.com/cjacks/archive/2006/09/08/exploring-manifests-part-2-defau
lt-namespaces-and-uac-manifests-in-windows-vista.aspx


This works in both XP and Vista (don't know about the others

From http://developmentnow.com/g/30_2006_5_0_0_750882/Sort-Arrows-in-ListView-Control
-in-NET-2-0.ht


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.