Click here to Skip to main content
12,404,895 members (70,487 online)
Click here to Skip to main content
Add your own
alternative version


195 bookmarked

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!

You may also be interested in...

Comments and Discussions

Generalsort within groups Pin
umeca745-Jan-06 22:49
memberumeca745-Jan-06 22:49 
GeneralXPListViewItem.UseItemStyleForSubItems is ignored Pin
Yax Ku'k Mo5-Jan-06 10:54
memberYax Ku'k Mo5-Jan-06 10:54 
GeneralChange row color Pin
[Neno]21-Nov-05 10:45
member[Neno]21-Nov-05 10:45 
GeneralStackOverFlow Pin
rafabgood19-Sep-05 2:48
memberrafabgood19-Sep-05 2:48 
GeneralRe: StackOverFlow Pin
rafabgood19-Sep-05 3:00
memberrafabgood19-Sep-05 3:00 
GeneralRe: StackOverFlow Pin
Moshe Taieb24-Oct-06 1:56
memberMoshe Taieb24-Oct-06 1:56 
GeneralRe: StackOverFlow Pin
lornen25-Dec-06 17:05
memberlornen25-Dec-06 17:05 
GeneralCompile Error Pin
Simon Pearson14-Sep-05 1:04
memberSimon Pearson14-Sep-05 1:04 
GeneralStackoverflowException Pin
laszlo varga2-Sep-05 11:23
susslaszlo varga2-Sep-05 11:23 
GeneralRe: StackoverflowException Pin
iixulf23-Mar-06 18:51
memberiixulf23-Mar-06 18:51 
GeneralUsing or not using Application.EnableVisualStyles(); Pin
Paulo Aboim Pinto4-Aug-05 0:57
memberPaulo Aboim Pinto4-Aug-05 0:57 
GeneralRe: Using or not using Application.EnableVisualStyles(); Pin
Paulo Aboim Pinto4-Aug-05 1:18
memberPaulo Aboim Pinto4-Aug-05 1:18 
GeneralIndicating that list is empty Pin
Paulo Aboim Pinto4-Aug-05 0:54
memberPaulo Aboim Pinto4-Aug-05 0:54 
GeneralGroup Headers Pin
Calum McLellan10-Jul-05 21:58
memberCalum McLellan10-Jul-05 21:58 
GeneralRe: Group Headers Pin
Calum McLellan15-Jul-05 9:39
memberCalum McLellan15-Jul-05 9:39 
GeneralSelection problem Pin
Mific996-Jul-05 7:58
memberMific996-Jul-05 7:58 
GeneralListViewItem DesignMode Pin
JP CADT30-Jun-05 21:26
memberJP CADT30-Jun-05 21:26 
QuestionCollapsable group? Pin
Kozmoz14-Jun-05 1:17
sussKozmoz14-Jun-05 1:17 
AnswerRe: Collapsable group? Pin
Acoustic15-Jun-05 4:30
memberAcoustic15-Jun-05 4:30 
GeneralAdd group manuel Pin
deltadk14-Apr-05 22:15
memberdeltadk14-Apr-05 22:15 
GeneralEnable the context menu only when an item is selected Pin
vxje6-Apr-05 23:44
membervxje6-Apr-05 23:44 
Generalbackground image Pin
marcplatvoet2-Mar-05 5:06
membermarcplatvoet2-Mar-05 5:06 
GeneralUsing foreach statement Pin
adamhb15-Dec-04 16:18
memberadamhb15-Dec-04 16:18 
GeneralRe: Using foreach statement Pin
Acoustic26-Dec-04 6:09
memberAcoustic26-Dec-04 6:09 
GeneralRe: Using foreach statement Pin
moon4415-Apr-05 11:09
membermoon4415-Apr-05 11:09 
GeneralAwesome Control Pin
tonybee7208-Dec-04 5:59
membertonybee7208-Dec-04 5:59 
GeneralRe: Awesome Control Pin
Acoustic26-Dec-04 6:08
memberAcoustic26-Dec-04 6:08 
QuestionIt doesn't work on Win2K? Pin
Nguy4-Nov-04 17:03
memberNguy4-Nov-04 17:03 
AnswerRe: It doesn't work on Win2K? Pin
Anonymous5-Nov-04 4:28
sussAnonymous5-Nov-04 4:28 
AnswerRe: It doesn't work on Win2K? Pin
Sana Sano5-Mar-06 15:02
memberSana Sano5-Mar-06 15:02 
GeneralVS.NET 2005 does exactly this Pin
benneh25-Oct-04 21:04
memberbenneh25-Oct-04 21:04 
GeneralRe: VS.NET 2005 does exactly this Pin
Acoustic26-Dec-04 6:11
memberAcoustic26-Dec-04 6:11 
GeneralGreat Job! Pin
tupacs0118-Oct-04 17:43
membertupacs0118-Oct-04 17:43 
GeneralRe: Great Job! Pin
Anonymous19-Oct-04 12:01
sussAnonymous19-Oct-04 12:01 
GeneralBackground Colour of ListViewItem Pin
focus_nz7-Oct-04 17:05
memberfocus_nz7-Oct-04 17:05 
GeneralRe: Background Colour of ListViewItem Pin
focus_nz7-Oct-04 17:34
memberfocus_nz7-Oct-04 17:34 
GeneralRe: Background Colour of ListViewItem Pin
Javier M27-Aug-05 7:17
memberJavier M27-Aug-05 7:17 
GeneralVB.NET Pin
DarkMercenary29-Sep-04 8:24
memberDarkMercenary29-Sep-04 8:24 
GeneralRe: VB.NET Pin
Anonymous2-Nov-04 5:41
sussAnonymous2-Nov-04 5:41 
GeneralMDI Application Pin
Richard Steele17-Aug-04 0:05
sussRichard Steele17-Aug-04 0:05 
Questionclick on listview item? Pin
marker2722-Jul-04 3:46
membermarker2722-Jul-04 3:46 
AnswerRe: click on listview item? Pin
Acoustic24-Jul-04 10:57
memberAcoustic24-Jul-04 10:57 
GeneralRe: click on listview item? Pin
wincomand2-Sep-04 3:05
memberwincomand2-Sep-04 3:05 
GeneralRe: click on listview item? Pin
Acoustic2-Sep-04 4:33
memberAcoustic2-Sep-04 4:33 
GeneralRe: click on listview item? Pin
wincomand2-Sep-04 21:13
memberwincomand2-Sep-04 21:13 
QuestionUsing custom grouping breaks images - any ideas? Pin
el Paulo®13-Jul-04 8:22
memberel Paulo®13-Jul-04 8:22 
AnswerRe: Using custom grouping breaks images - any ideas? Pin
Acoustic24-Jul-04 10:56
memberAcoustic24-Jul-04 10:56 
GeneralSmall bug fix Pin
Kabal3038-Jul-04 20:10
memberKabal3038-Jul-04 20:10 
GeneralMFC/C++ .NET application Pin
Victor Bravo10-Jun-04 11:45
memberVictor Bravo10-Jun-04 11:45 
GeneralRe: MFC/C++ .NET application Pin
Acoustic10-Jun-04 17:31
memberAcoustic10-Jun-04 17:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    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.160721.1 | Last Updated 28 May 2004
Article Copyright 2004 by TylerBrinks
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid