Click here to Skip to main content
12,295,791 members (25,234 online)
Click here to Skip to main content
Add your own
alternative version


327 bookmarked

SuperGrid - Yet Another listview control

, 8 Dec 1999 CPOL
Rate this:
Please Sign up or sign in to vote.
A combination list control and tree control with checkbox capability

Sample Image

Okay yet another full blown ownerdraw listview control with a tree like thing in the first column.

What´s new:

  • subitems now supports images
  • improved sorting
  • bugfixes reported by you.

please see the history section in the SuperGridCtrl.cpp file for further reading.


The listview control has support for editing subitems and basic user navigation. To edit an item hit the Enter key to start editing, when done editing, hit the Enter Key again. The listview control also has support for sorting items, drag and drop, basic scroll, autoscroll and autoexpand when dragging an item over another item. The listview control supports Insert/Delete items and you can use the +,-,* keys to expand/collapse items. The listview control does NOT support header drag/drop operations. Thanks for all them positive emails I have recived. If you have any suggestions to some future version let me know.


The class CSuperGridCtrl is derived from CListCtrl and it has a nested class called CTreeItem. The CTreeItem represents a node in a linked list. Each CTreeItem has a CObList representing its children and a few data members telling you the current status on the node e.g expanded, haschildren etc. Each listview item has a pointer to the CTreeItem(stored in the lParam of course). The CTreeItem has an associated class called CItemInfo. The CItemInfo class represents the data in the listview. This class is just a wrapper for the CStringArray, each item in the array represents a subitem. You may have to modify this class to suit your logical data-representation in the listview. In each CItemInfo you may associate a controltype: default controltype is an edit-control. In the source code you will find an example on how to associate a combobox control to a specific CItemInfo and how to initalize the combobox with default values.

Another standard control which is implicit in the listview control are the checkbox-control, by using the LVS_EX_CHECKBOXES style you will have this control for free, nothing new here....but in the CItemInfo class you will be able to test which items are checked. The class CMySuperGrid which is derived from CSuperGridCtrl shows you how to initalize the grid, insert root items, insert items, sort items, associate controltypes and how to implement 'print preview' selected or checked items depending on which extended style you have set, it also shows you have to search for items, select items, delete items and how to set the current listview icon and individual cell color. The source code shows you how to use the listview control in a CView derived class and in a CDialog derived class.

The listview control was built with Visual C++ 6.0 (sp10) level 8 on Windows 2000 beta 9, I don't remember the Netcard ID Wink | ;-) .

In the SuperGridCtrl.h header file you will find further information/documentation on how to use this listview control. I have included a "history" section in the SuperGridCtrl.cpp file.

Drop me a line when you find that bug or if you have any comments / suggestions / improvement at all to this listview control.


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


About the Author

Allan Nielsen
Switzerland Switzerland
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionHow can I realize the directory tree like the listview? Pin
blestrabbit13-Apr-05 17:02
memberblestrabbit13-Apr-05 17:02 
QuestionHow to do sorting depending on column data type? Pin
NikoletinaBursac8-Mar-05 7:43
memberNikoletinaBursac8-Mar-05 7:43 
GeneralDifferent Item Height Pin
hypercor17-Feb-05 1:20
memberhypercor17-Feb-05 1:20 
GeneralRe: Different Item Height Pin
iliyang16-Jun-05 9:20
memberiliyang16-Jun-05 9:20 
Generalmoving rows Pin
meir_elkabetz@hotmail.com16-Feb-05 4:13
sussmeir_elkabetz@hotmail.com16-Feb-05 4:13 
Questionhow can set a col is readonly Pin
Anonymous3-Nov-04 18:41
sussAnonymous3-Nov-04 18:41 
GeneralA Definite Bug Pin
Bill Ross29-Sep-04 7:30
sussBill Ross29-Sep-04 7:30 
QuestionCan I use this in .net visual c++ Pin
Chetan.M22-Sep-04 21:22
memberChetan.M22-Sep-04 21:22 
GeneralSorting is kinda weak Pin
LakeFerrits10-Aug-04 11:15
memberLakeFerrits10-Aug-04 11:15 
GeneralVERY hard to use Pin
jtorjo19-Jul-04 22:05
memberjtorjo19-Jul-04 22:05 
GeneralRe: VERY hard to use Pin
@llan25-Feb-05 21:02
member@llan25-Feb-05 21:02 
>I'm sorry to say
hey don't beD'Oh! | :doh:
>but while I'm sure you've worked a lot on it, and the UI looks great -,
I worked on this 3 weeks in 1999 and I am sorry I didn't factored the interface back then, I was in a hurry...and I figured perhaps someone else could use this code, so I uploaded it here...Rose | [Rose]
>Especially, what really killed me, was the fact that when the user clicks >a "Collapse" button, my list items are DELETED
you actually did not take the time to read the article, did you now Poke tongue | ;-P
>Then, I had to create a custom mechanism for uniquely identifying an item
Confused | :confused:
I hope your nightmares are over Smile | :) .

I am sorry that you didn't get a free ride with this control here.Big Grin | :-D

keep up the good work.

GeneralRe: VERY hard to use Pin
jtorjo26-Feb-05 8:58
memberjtorjo26-Feb-05 8:58 
GeneralThis is VERY difficult to customize Pin
brchris19-Jun-04 8:25
memberbrchris19-Jun-04 8:25 
GeneralRe: This is VERY difficult to customize Pin
brdavid5-Mar-05 8:43
memberbrdavid5-Mar-05 8:43 
GeneralRe: This is VERY difficult to customize Pin
icecube418-Feb-05 9:06
sussicecube418-Feb-05 9:06 
GeneralEasy way to place this in custom app Pin
Anonymous5-Jun-04 0:48
sussAnonymous5-Jun-04 0:48 
QuestionHow to use CTreeItem class and its member function in SuperVw class? Pin
benax.von19-May-04 22:18
memberbenax.von19-May-04 22:18 
GeneralUsing this control without ImageList Pin
JimmyO19-May-04 4:11
memberJimmyO19-May-04 4:11 
GeneralControl flckers during column resize Pin
Harnash12-May-04 4:19
memberHarnash12-May-04 4:19 
GeneralRe: Control flckers during column resize Pin
Martin Richter19-May-04 2:11
memberMartin Richter19-May-04 2:11 
GeneralRe: Control flckers during column resize Pin
Harnash19-May-04 2:19
memberHarnash19-May-04 2:19 
QuestionIs this a COM component? Pin
ZippyBubbleHead14-Apr-04 3:41
memberZippyBubbleHead14-Apr-04 3:41 
AnswerRe: Is this a COM component? Pin
Martin Richter19-May-04 2:12
memberMartin Richter19-May-04 2:12 
Questionhow to fix the tree column? Pin
jingdeyi1-Apr-04 21:38
memberjingdeyi1-Apr-04 21:38 
AnswerRe: how to fix the tree column? Pin
Martin Richter19-May-04 2:13
memberMartin Richter19-May-04 2:13 
GeneralRe: how to fix the tree column? Pin
Raymond S3-Jun-04 11:15
memberRaymond S3-Jun-04 11:15 
GeneralRe: how to fix the tree column? Pin
Martin Richter3-Jun-04 19:42
memberMartin Richter3-Jun-04 19:42 
GeneralRe: how to fix the tree column? Pin
Raymond S4-Jun-04 4:57
memberRaymond S4-Jun-04 4:57 
GeneralRe: how to fix the tree column? Pin
Raymond S4-Jun-04 5:07
memberRaymond S4-Jun-04 5:07 
GeneralScrollbar doesn't work in XP! Pin
tungpth23-Mar-04 19:01
membertungpth23-Mar-04 19:01 
QuestionHow can I change Subitemtext Pin
_jaromir_7-Mar-04 23:57
member_jaromir_7-Mar-04 23:57 
AnswerRe: How can I change Subitemtext Pin
jingdeyi7-Apr-04 14:16
memberjingdeyi7-Apr-04 14:16 
GeneralRe: How can I change Subitemtext Pin
王健10-Aug-04 15:17
member王健10-Aug-04 15:17 
GeneralMaybe I found a bug Pin
lxz22-Feb-04 20:00
memberlxz22-Feb-04 20:00 
QuestionDROPDOWN comboboxes? Pin
Randi10-Feb-04 13:42
memberRandi10-Feb-04 13:42 
AnswerRe: DROPDOWN comboboxes? Pin
r_p_e7-Mar-04 5:08
sussr_p_e7-Mar-04 5:08 
GeneralRe: DROPDOWN comboboxes? Pin
Randi8-Mar-04 6:22
memberRandi8-Mar-04 6:22 
GeneralRe: DROPDOWN comboboxes? Pin
r_p_e9-Mar-04 4:05
sussr_p_e9-Mar-04 4:05 
GeneralReordering of root items using drag-and-drop Pin
Urban Olars8-Feb-04 20:47
memberUrban Olars8-Feb-04 20:47 
GeneralUse this class with eVC for Pocket PC Pin
Bui Huy Kien13-Jan-04 21:45
memberBui Huy Kien13-Jan-04 21:45 
GeneralRe: Use this class with eVC for Pocket PC Pin
Johann Gerell13-Jan-04 22:07
memberJohann Gerell13-Jan-04 22:07 
GeneralThere is a trivial bug in CSuperGridCtrl::GetPrevRoot Pin
hackcom4-Jan-04 14:35
memberhackcom4-Jan-04 14:35 
GeneralRe: There is a trivial bug in CSuperGridCtrl::GetPrevRoot Pin
cristitomi4-Apr-07 21:34
membercristitomi4-Apr-07 21:34 
GeneralLVS_EX_FLATSB style caused no scroll bar Pin
LVS_EX_FLATSB28-Dec-03 19:06
sussLVS_EX_FLATSB28-Dec-03 19:06 
GeneralRe: LVS_EX_FLATSB style caused no scroll bar Pin
zhanghk3-Nov-04 20:32
memberzhanghk3-Nov-04 20:32 
GeneralExcellent Control Pin
Halid Niyaz16-Dec-03 23:04
memberHalid Niyaz16-Dec-03 23:04 
GeneralNeed help: Missing checkbox Pin
gregoire.b18-Nov-03 10:17
membergregoire.b18-Nov-03 10:17 
Generalif i don't want to use MFC Pin
Alex V. Kayuchkin17-Nov-03 23:39
memberAlex V. Kayuchkin17-Nov-03 23:39 
GeneralRe: if i don't want to use MFC Pin
shuaicarr25-Jan-07 20:50
membershuaicarr25-Jan-07 20:50 
Generalflicker when inserting items... Pin
kcp743-Nov-03 23:42
memberkcp743-Nov-03 23:42 

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.160525.2 | Last Updated 9 Dec 1999
Article Copyright 1999 by Allan Nielsen
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid