Click here to Skip to main content
11,409,854 members (44,687 online)
Click here to Skip to main content

ListView Grouping XP Style

, 27 May 2004 CPOL
Rate this:
Please Sign up or sign in to vote.
Group ListView items by any column, XP style.

Sample Image - GroupListView.jpg


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.


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.


  • May 25, 2004 - Support for bolded group headers


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


About the Author

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

Comments and Discussions

GeneralXPListViewItem.UseItemStyleForSubItems is ignored PinmemberYax Ku'k Mo5-Jan-06 11:54 
GeneralChange row color Pinmember[Neno]21-Nov-05 11:45 
GeneralStackOverFlow Pinmemberrafabgood19-Sep-05 3:48 
GeneralRe: StackOverFlow Pinmemberrafabgood19-Sep-05 4:00 
GeneralRe: StackOverFlow PinmemberMoshe Taieb24-Oct-06 2:56 
GeneralRe: StackOverFlow Pinmemberlornen25-Dec-06 18:05 
GeneralCompile Error PinmemberSimon Pearson14-Sep-05 2:04 
GeneralStackoverflowException Pinsusslaszlo varga2-Sep-05 12:23 
GeneralRe: StackoverflowException Pinmemberiixulf23-Mar-06 19:51 
GeneralUsing or not using Application.EnableVisualStyles(); PinmemberPaulo Aboim Pinto4-Aug-05 1:57 
GeneralRe: Using or not using Application.EnableVisualStyles(); PinmemberPaulo Aboim Pinto4-Aug-05 2:18 
GeneralIndicating that list is empty PinmemberPaulo Aboim Pinto4-Aug-05 1:54 
GeneralGroup Headers PinmemberCalum McLellan10-Jul-05 22:58 
GeneralRe: Group Headers PinmemberCalum McLellan15-Jul-05 10:39 
GeneralSelection problem PinmemberMific996-Jul-05 8:58 
GeneralListViewItem DesignMode PinmemberJP CADT30-Jun-05 22:26 
QuestionCollapsable group? PinsussKozmoz14-Jun-05 2:17 
AnswerRe: Collapsable group? PinmemberAcoustic15-Jun-05 5:30 
GeneralAdd group manuel Pinmemberdeltadk14-Apr-05 23:15 
GeneralEnable the context menu only when an item is selected Pinmembervxje7-Apr-05 0:44 
Generalbackground image Pinmembermarcplatvoet2-Mar-05 6:06 
GeneralUsing foreach statement Pinmemberadamhb15-Dec-04 17:18 
GeneralRe: Using foreach statement PinmemberAcoustic26-Dec-04 7:09 
GeneralRe: Using foreach statement Pinmembermoon4415-Apr-05 12:09 
GeneralAwesome Control Pinmembertonybee7208-Dec-04 6:59 

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.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150414.5 | Last Updated 28 May 2004
Article Copyright 2004 by TylerBrinks
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid