Click here to Skip to main content
Licence CPOL
First Posted 14 May 2004
Views 236,946
Downloads 2,255
Bookmarked 181 times

ListView Grouping XP Style

By TylerBrinks | 27 May 2004
Group ListView items by any column, XP style.
3 votes, 5.6%
1
2 votes, 3.7%
2
1 vote, 1.9%
3
12 votes, 22.2%
4
36 votes, 66.7%
5
4.64/5 - 54 votes
5 removed
μ 4.42, σa 1.91 [?]

Sample Image - GroupListView.jpg

Introduction

The controls included with Microsoft’s IDE have always been feature rich. However, Microsoft always seems to leave out as many features as they include. The ListView control is no exception to this rule. This project aims at exposing and wrapping a few cool features. First to note is the ability to group items. In Windows Explorer’s View menu, the “Arrange Icon by” menu has a “Show in Groups” option. This allows the ListView to arrange items logically into groups, generally based on file type. The next feature is the ability to set an image as the background of a ListView, whether tiled or a single image. Your My Music folder demonstrates the concept, with a music note image in the lower right hand corner. This project extends the standard ListView with the help of the Windows API to give a more feature rich control.

Code

All the dirty work happens in the ListviewAPI class. Don’t be intimidated if you’ve never used any Windows API. The code simply wraps the SendMessage API using a handful of overrides. The rest is just constants required by the API (documentation available on MSDN).

I’ll spare a long explanation. Download the test project and see for yourself. I included a bitmap file (Note.bmp) to use for setting the background image. You’ll notice, there is extra padding at the bottom of the bitmap. This is because setting the image yOffsetPercent to 100 causes the image to drop below the bottom of the ListView. However, setting the offset to 99 or less causes strange positioning when resizing the window.

History

  • May 25, 2004 - Support for bolded group headers

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

TylerBrinks

Web Developer
PageLabs
United States United States

Member

Follow on Twitter Follow on Twitter
I'm the founder of PageLabs, a web-based performance and SEO optimization site.

Give your site a boost in performance, even take a free speed test!
 
http://www.pagelabs.com

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 4 PinmvpDavidCrow10:39 9 Dec '10  
GeneralXPListview groupings doesn't show... Pinmembernardz.slasher16:38 22 Jul '07  
GeneralRe: XPListview groupings doesn't show... PinmemberAcoustic6:43 23 Jul '07  
GeneralIterating thru items Pinmembermichaeldjackson12:26 29 Jan '07  
QuestionDon't see anything? PinmemberAloys Akkerman1:52 11 Aug '06  
AnswerRe: Don't see anything? PinmemberAloys Akkerman12:26 13 Aug '06  
AnswerRe: Don't see anything? Pinmembermoshe.taieb22:59 23 Oct '06  
GeneralGrouping Does not work in win2000 Pinmemberahaudi23:04 3 Aug '06  
GeneralRe: Grouping Does not work in win2000 PinmemberAcoustic9:40 6 Aug '06  
QuestionSource code use Pinmemberdai yuan23:42 20 Jul '06  
AnswerRe: Source code use PinmemberAcoustic8:15 22 Jul '06  
GeneralRe: Source code use Pinmemberdai yuan16:20 23 Jul '06  
GeneralRe: Source code use PinmemberBlueLoveCyn19:26 27 Mar '07  
GeneralFound some problem PinmemberPunprom Kasemsant4:13 2 Jun '06  
Generalimprovement emptyAutoGroupText for empty cells PinmemberJosema15:04 23 Mar '06  
QuestionHow can I change the Color of the Collumns Headers Pinmemberdvadim5:46 23 Mar '06  
AnswerRe: How can I change the Color of the Collumns Headers PinmemberAcoustic9:39 6 Aug '06  
Generalall event do not execute after a MessageBox Show Pinmemberbyshome22:58 19 Mar '06  
GeneralSelectedIndex Pinmembermrabie18:37 16 Mar '06  
GeneralRe: SelectedIndex Pinmembermrabie19:43 16 Mar '06  
AnswerRe: SelectedIndex PinmemberGil158:22 17 Jul '07  
QuestionRe: SelectedIndex PinmemberGil158:28 17 Jul '07  
GeneralRe: SelectedIndex PinmemberMember 370804911:48 4 Dec '09  
Generalsort within groups Pinmemberumeca7423:49 5 Jan '06  
GeneralXPListViewItem.UseItemStyleForSubItems is ignored PinmemberYax Ku'k Mo11:54 5 Jan '06  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120210.1 | Last Updated 28 May 2004
Article Copyright 2004 by TylerBrinks
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid