Click here to Skip to main content
13,287,116 members (48,912 online)
Click here to Skip to main content
Add your own
alternative version


194 bookmarked
Posted 14 May 2004

ListView Grouping XP Style

, 27 May 2004
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

QuestionIn fact, what I'm really concerned about is how to enable the "Tiles" view Pin
Member 121873364-Dec-15 22:31
memberMember 121873364-Dec-15 22:31 
QuestionLVS_ICON mode Pin
Plamen Petrov16-May-12 4:43
memberPlamen Petrov16-May-12 4:43 
GeneralMy vote of 4 Pin
DavidCrow9-Dec-10 10:39
mvpDavidCrow9-Dec-10 10:39 
GeneralXPListview groupings doesn't show... Pin
nardz.slasher22-Jul-07 16:38
membernardz.slasher22-Jul-07 16:38 
GeneralRe: XPListview groupings doesn't show... Pin
Acoustic23-Jul-07 6:43
memberAcoustic23-Jul-07 6:43 
GeneralIterating thru items Pin
michaeldjackson29-Jan-07 12:26
membermichaeldjackson29-Jan-07 12:26 
I've made the correction to XPListViewItemCollections as noted in previous posts in this board.

I'm trying to iterate thru the items in the listview, but it continues to error out.

My code:
For i As Integer = 0 To .lvTags.Items.Count - 1

QuestionDon't see anything? Pin
Aloys Akkerman11-Aug-06 1:52
memberAloys Akkerman11-Aug-06 1:52 
AnswerRe: Don't see anything? Pin
Aloys Akkerman13-Aug-06 12:26
memberAloys Akkerman13-Aug-06 12:26 
AnswerRe: Don't see anything? Pin
moshe.taieb23-Oct-06 22:59
membermoshe.taieb23-Oct-06 22:59 
GeneralGrouping Does not work in win2000 Pin
ahaudi3-Aug-06 23:04
memberahaudi3-Aug-06 23:04 
GeneralRe: Grouping Does not work in win2000 Pin
Acoustic6-Aug-06 9:40
memberAcoustic6-Aug-06 9:40 
QuestionSource code use Pin
dai yuan20-Jul-06 23:42
memberdai yuan20-Jul-06 23:42 
AnswerRe: Source code use Pin
Acoustic22-Jul-06 8:15
memberAcoustic22-Jul-06 8:15 
GeneralRe: Source code use Pin
dai yuan23-Jul-06 16:20
memberdai yuan23-Jul-06 16:20 
GeneralRe: Source code use Pin
BlueLoveCyn27-Mar-07 19:26
memberBlueLoveCyn27-Mar-07 19:26 
GeneralFound some problem Pin
Punprom Kasemsant2-Jun-06 4:13
memberPunprom Kasemsant2-Jun-06 4:13 
Generalimprovement emptyAutoGroupText for empty cells Pin
Josema23-Mar-06 15:04
memberJosema23-Mar-06 15:04 
QuestionHow can I change the Color of the Collumns Headers Pin
dvadim23-Mar-06 5:46
memberdvadim23-Mar-06 5:46 
AnswerRe: How can I change the Color of the Collumns Headers Pin
Acoustic6-Aug-06 9:39
memberAcoustic6-Aug-06 9:39 
Generalall event do not execute after a MessageBox Show Pin
byshome19-Mar-06 22:58
memberbyshome19-Mar-06 22:58 
GeneralSelectedIndex Pin
mrabie16-Mar-06 18:37
membermrabie16-Mar-06 18:37 
GeneralRe: SelectedIndex Pin
mrabie16-Mar-06 19:43
membermrabie16-Mar-06 19:43 
AnswerRe: SelectedIndex Pin
Gil1517-Jul-07 8:22
memberGil1517-Jul-07 8:22 
QuestionRe: SelectedIndex Pin
Gil1517-Jul-07 8:28
memberGil1517-Jul-07 8:28 
GeneralRe: SelectedIndex Pin
Member 37080494-Dec-09 11:48
memberMember 37080494-Dec-09 11:48 
Generalsort within groups Pin
umeca745-Jan-06 23:49
memberumeca745-Jan-06 23:49 
GeneralXPListViewItem.UseItemStyleForSubItems is ignored Pin
Yax Ku'k Mo5-Jan-06 11:54
memberYax Ku'k Mo5-Jan-06 11:54 
GeneralChange row color Pin
[Neno]21-Nov-05 11:45
member[Neno]21-Nov-05 11:45 
GeneralStackOverFlow Pin
rafabgood19-Sep-05 3:48
memberrafabgood19-Sep-05 3:48 
GeneralRe: StackOverFlow Pin
rafabgood19-Sep-05 4:00
memberrafabgood19-Sep-05 4:00 
GeneralRe: StackOverFlow Pin
Moshe Taieb24-Oct-06 2:56
memberMoshe Taieb24-Oct-06 2:56 
GeneralRe: StackOverFlow Pin
lornen25-Dec-06 18:05
memberlornen25-Dec-06 18:05 
GeneralCompile Error Pin
Simon Pearson14-Sep-05 2:04
memberSimon Pearson14-Sep-05 2:04 
GeneralStackoverflowException Pin
laszlo varga2-Sep-05 12:23
susslaszlo varga2-Sep-05 12:23 
GeneralRe: StackoverflowException Pin
iixulf23-Mar-06 19:51
memberiixulf23-Mar-06 19:51 
GeneralUsing or not using Application.EnableVisualStyles(); Pin
Paulo Aboim Pinto4-Aug-05 1:57
memberPaulo Aboim Pinto4-Aug-05 1:57 
GeneralRe: Using or not using Application.EnableVisualStyles(); Pin
Paulo Aboim Pinto4-Aug-05 2:18
memberPaulo Aboim Pinto4-Aug-05 2:18 
GeneralIndicating that list is empty Pin
Paulo Aboim Pinto4-Aug-05 1:54
memberPaulo Aboim Pinto4-Aug-05 1:54 
GeneralGroup Headers Pin
Calum McLellan10-Jul-05 22:58
memberCalum McLellan10-Jul-05 22:58 
GeneralRe: Group Headers Pin
Calum McLellan15-Jul-05 10:39
memberCalum McLellan15-Jul-05 10:39 
GeneralSelection problem Pin
Mific996-Jul-05 8:58
memberMific996-Jul-05 8:58 
GeneralListViewItem DesignMode Pin
JP CADT30-Jun-05 22:26
memberJP CADT30-Jun-05 22:26 
QuestionCollapsable group? Pin
Kozmoz14-Jun-05 2:17
sussKozmoz14-Jun-05 2:17 
AnswerRe: Collapsable group? Pin
Acoustic15-Jun-05 5:30
memberAcoustic15-Jun-05 5:30 
GeneralAdd group manuel Pin
deltadk14-Apr-05 23:15
memberdeltadk14-Apr-05 23:15 
GeneralEnable the context menu only when an item is selected Pin
vxje7-Apr-05 0:44
membervxje7-Apr-05 0:44 
Generalbackground image Pin
marcplatvoet2-Mar-05 6:06
membermarcplatvoet2-Mar-05 6:06 
GeneralUsing foreach statement Pin
adamhb15-Dec-04 17:18
memberadamhb15-Dec-04 17:18 
GeneralRe: Using foreach statement Pin
Acoustic26-Dec-04 7:09
memberAcoustic26-Dec-04 7:09 
GeneralRe: Using foreach statement Pin
moon4415-Apr-05 12:09
membermoon4415-Apr-05 12:09 

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.

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