Click here to Skip to main content
Click here to Skip to main content

ListView Grouping XP Style

By , 27 May 2004
 

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
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
Follow on   Twitter

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

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionLVS_ICON modememberPlamen Petrov16-May-12 3:43 
GeneralMy vote of 4mvpDavidCrow9-Dec-10 9:39 
GeneralXPListview groupings doesn't show...membernardz.slasher22-Jul-07 15:38 
GeneralRe: XPListview groupings doesn't show...memberAcoustic23-Jul-07 5:43 
GeneralIterating thru itemsmembermichaeldjackson29-Jan-07 11:26 
QuestionDon't see anything?memberAloys Akkerman11-Aug-06 0:52 
AnswerRe: Don't see anything?memberAloys Akkerman13-Aug-06 11:26 
AnswerRe: Don't see anything?membermoshe.taieb23-Oct-06 21:59 
GeneralGrouping Does not work in win2000memberahaudi3-Aug-06 22:04 
GeneralRe: Grouping Does not work in win2000memberAcoustic6-Aug-06 8:40 
QuestionSource code usememberdai yuan20-Jul-06 22:42 
AnswerRe: Source code usememberAcoustic22-Jul-06 7:15 
GeneralRe: Source code usememberdai yuan23-Jul-06 15:20 
GeneralRe: Source code usememberBlueLoveCyn27-Mar-07 18:26 
GeneralFound some problemmemberPunprom Kasemsant2-Jun-06 3:13 
Generalimprovement emptyAutoGroupText for empty cellsmemberJosema23-Mar-06 14:04 
QuestionHow can I change the Color of the Collumns Headersmemberdvadim23-Mar-06 4:46 
AnswerRe: How can I change the Color of the Collumns HeadersmemberAcoustic6-Aug-06 8:39 
Generalall event do not execute after a MessageBox Showmemberbyshome19-Mar-06 21:58 
GeneralSelectedIndexmembermrabie16-Mar-06 17:37 
GeneralRe: SelectedIndexmembermrabie16-Mar-06 18:43 
AnswerRe: SelectedIndexmemberGil1517-Jul-07 7:22 
QuestionRe: SelectedIndexmemberGil1517-Jul-07 7:28 
GeneralRe: SelectedIndexmemberMember 37080494-Dec-09 10:48 
Generalsort within groupsmemberumeca745-Jan-06 22:49 
GeneralXPListViewItem.UseItemStyleForSubItems is ignoredmemberYax Ku'k Mo5-Jan-06 10:54 
GeneralChange row colormember[Neno]21-Nov-05 10:45 
GeneralStackOverFlowmemberrafabgood19-Sep-05 2:48 
GeneralRe: StackOverFlowmemberrafabgood19-Sep-05 3:00 
GeneralRe: StackOverFlowmemberMoshe Taieb24-Oct-06 1:56 
GeneralRe: StackOverFlowmemberlornen25-Dec-06 17:05 
GeneralCompile ErrormemberSimon Pearson14-Sep-05 1:04 
GeneralStackoverflowExceptionsusslaszlo varga2-Sep-05 11:23 
GeneralRe: StackoverflowExceptionmemberiixulf23-Mar-06 18:51 
GeneralUsing or not using Application.EnableVisualStyles();memberPaulo Aboim Pinto4-Aug-05 0:57 
GeneralRe: Using or not using Application.EnableVisualStyles();memberPaulo Aboim Pinto4-Aug-05 1:18 
GeneralIndicating that list is emptymemberPaulo Aboim Pinto4-Aug-05 0:54 
GeneralGroup HeadersmemberCalum McLellan10-Jul-05 21:58 
GeneralRe: Group HeadersmemberCalum McLellan15-Jul-05 9:39 
GeneralSelection problemmemberMific996-Jul-05 7:58 
GeneralListViewItem DesignModememberJP CADT30-Jun-05 21:26 
QuestionCollapsable group?sussKozmoz14-Jun-05 1:17 
AnswerRe: Collapsable group?memberAcoustic15-Jun-05 4:30 
GeneralAdd group manuelmemberdeltadk14-Apr-05 22:15 
GeneralEnable the context menu only when an item is selectedmembervxje6-Apr-05 23:44 
Generalbackground imagemembermarcplatvoet2-Mar-05 5:06 
GeneralUsing foreach statementmemberadamhb15-Dec-04 16:18 
GeneralRe: Using foreach statementmemberAcoustic26-Dec-04 6:09 
GeneralRe: Using foreach statementmembermoon4415-Apr-05 11:09 
GeneralAwesome Controlmembertonybee7208-Dec-04 5:59 

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

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