Click here to Skip to main content
11,490,973 members (70,905 online)
Click here to Skip to main content

SuperGrid - Yet Another listview control

, 8 Dec 1999 CPOL 618K 8.5K 326
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.

Features:

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.

Note:

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.

License

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

Share

About the Author

Allan Nielsen

Switzerland Switzerland
No Biography provided

Comments and Discussions

 
BugBug on CSuperGrid::GetCount - The *Bug* and the *Solution*. Pin
wangjianhua20059-Oct-14 18:16
memberwangjianhua20059-Oct-14 18:16 
GeneralMy vote of 5 Pin
mxs8108-Aug-13 1:04
membermxs8108-Aug-13 1:04 
QuestionFOUND How Implement CheckBox Capture Event [modified] Pin
Herusetiyadi7-Jun-13 9:24
memberHerusetiyadi7-Jun-13 9:24 
Questionocx file for use in VB6 Pin
L B Choudhury28-Jan-13 20:06
memberL B Choudhury28-Jan-13 20:06 
QuestionHow to real delete all, include column header? [modified] Pin
Jason Tian19-Nov-11 20:55
memberJason Tian19-Nov-11 20:55 
GeneralRe: How to real delete all, include column header? Pin
@llan9-Dec-11 6:26
member@llan9-Dec-11 6:26 
Questionhow to add Icon To this SuperList Pin
thanhl0v37-Mar-11 17:54
memberthanhl0v37-Mar-11 17:54 
QuestionIs there a way to edit the fields? Pin
matt200023-Jan-09 10:03
membermatt200023-Jan-09 10:03 
QuestionDialog based application [modified] Pin
krishnanand2-Jul-08 4:16
memberkrishnanand2-Jul-08 4:16 
QuestionColumn problem when dynamic setting Pin
Eva ranee18-Sep-07 0:50
memberEva ranee18-Sep-07 0:50 
QuestionMultiple column sortin Pin
sharathgowda10-Jul-07 3:35
membersharathgowda10-Jul-07 3:35 
GeneralIt looks so good. Pin
N1i2c3k8-Jun-07 20:31
memberN1i2c3k8-Jun-07 20:31 
QuestionI need some help about delete items Pin
Starsrain4-Apr-07 16:37
memberStarsrain4-Apr-07 16:37 
QuestionDo you have a VB OO compatible version or OCX ? Pin
MCMikey6921-Mar-07 8:40
memberMCMikey6921-Mar-07 8:40 
GeneralBug in check boxes Pin
_faraz12-Mar-07 1:48
member_faraz12-Mar-07 1:48 
GeneralRe: Bug in check boxes Pin
_faraz12-Mar-07 2:33
member_faraz12-Mar-07 2:33 
Questionhow do you implement it ? Pin
shuaicarr25-Jan-07 19:24
membershuaicarr25-Jan-07 19:24 
QuestionNested List-Control with Column-Headers ? Pin
webspektive7-Dec-06 5:34
memberwebspektive7-Dec-06 5:34 
GeneralReally useful but is it possible? [modified] Pin
crazydave2223-Oct-06 5:27
membercrazydave2223-Oct-06 5:27 
Question1. Does anybody know how to implement Multiselection ( Rows ) into this fine piece of code? Pin
hawonjeon10-Oct-06 21:26
memberhawonjeon10-Oct-06 21:26 
AnswerRe: 1. Does anybody know how to implement Multiselection ( Rows ) into this fine piece of code? Pin
tangshengye29-Oct-08 3:24
membertangshengye29-Oct-08 3:24 
Generalproblem with add 100 000 nodes Pin
nikomsj14-Sep-06 4:16
membernikomsj14-Sep-06 4:16 
Generalbug Pin
kingship9-Aug-06 7:32
memberkingship9-Aug-06 7:32 
GeneralNeed Some help Pin
konstantinos_100028-Jul-06 1:42
memberkonstantinos_100028-Jul-06 1:42 
Generalvery good Pin
bishanhu6-Jun-06 4:37
memberbishanhu6-Jun-06 4:37 
Generalwrong version in the download link Pin
banbanyy8-Feb-06 2:39
memberbanbanyy8-Feb-06 2:39 
Questionany one immplemented LVS_EX_HEADERDRAGDROP to this?? Pin
kumar_anand9-Dec-05 0:19
memberkumar_anand9-Dec-05 0:19 
QuestionHow to use SetItemData? Pin
HarveyLiu14-Aug-05 18:49
memberHarveyLiu14-Aug-05 18:49 
AnswerRe: How to use SetItemData? Pin
Danila Korablin25-Jun-07 6:34
memberDanila Korablin25-Jun-07 6:34 
QuestionHow to change Parent Item Pin
Tu Tran15-Jul-05 14:52
memberTu Tran15-Jul-05 14:52 
Hi guru,
I am a newbie in C++ Programming. I am trying to use this control on my bill of material (BOM) program. I have a list of BOM (ParentNo, ChildNo, Description, etc) that I want to display using this control. So, I use loop (for i = ...) to loop through the list and InsertItem(ParentNo, ChildNo). How do I write the loop program to insert all the ChildNo using ParentNo as the Parent. Please Note: ParwentNo is not displayed, it's only used to specified where the ChildNo belonged to. Thank you for all your help and suggestion.

Tom.


Generalset check box after icons Pin
sammmmmy8-Jul-05 0:55
membersammmmmy8-Jul-05 0:55 
GeneralRe: set check box after icons Pin
sammmmmy8-Jul-05 1:06
membersammmmmy8-Jul-05 1:06 
Generalvery good,Thakns Pin
hpxs21-Jun-05 18:08
memberhpxs21-Jun-05 18:08 
QuestionHow can I realize the directory tree like the listview? Pin
blestrabbit13-Apr-05 18:02
memberblestrabbit13-Apr-05 18:02 
QuestionHow to do sorting depending on column data type? Pin
NikoletinaBursac8-Mar-05 8:43
memberNikoletinaBursac8-Mar-05 8:43 
GeneralDifferent Item Height Pin
hypercor17-Feb-05 2:20
memberhypercor17-Feb-05 2:20 
GeneralRe: Different Item Height Pin
iliyang16-Jun-05 10:20
memberiliyang16-Jun-05 10:20 
Generalmoving rows Pin
meir_elkabetz@hotmail.com16-Feb-05 5:13
sussmeir_elkabetz@hotmail.com16-Feb-05 5:13 
Questionhow can set a col is readonly Pin
Anonymous3-Nov-04 19:41
sussAnonymous3-Nov-04 19:41 
GeneralA Definite Bug Pin
Bill Ross29-Sep-04 8:30
sussBill Ross29-Sep-04 8:30 
QuestionCan I use this in .net visual c++ Pin
Chetan.M22-Sep-04 22:22
memberChetan.M22-Sep-04 22:22 
GeneralSorting is kinda weak Pin
LakeFerrits10-Aug-04 12:15
memberLakeFerrits10-Aug-04 12:15 
GeneralVERY hard to use Pin
jtorjo19-Jul-04 23:05
memberjtorjo19-Jul-04 23:05 
GeneralRe: VERY hard to use Pin
@llan25-Feb-05 22:02
member@llan25-Feb-05 22:02 
GeneralRe: VERY hard to use Pin
jtorjo26-Feb-05 9:58
memberjtorjo26-Feb-05 9:58 
GeneralThis is VERY difficult to customize Pin
brchris19-Jun-04 9:25
memberbrchris19-Jun-04 9:25 
GeneralRe: This is VERY difficult to customize Pin
brdavid5-Mar-05 9:43
memberbrdavid5-Mar-05 9:43 
GeneralRe: This is VERY difficult to customize Pin
icecube418-Feb-05 10:06
sussicecube418-Feb-05 10:06 
GeneralEasy way to place this in custom app Pin
Anonymous5-Jun-04 1:48
sussAnonymous5-Jun-04 1:48 
QuestionHow to use CTreeItem class and its member function in SuperVw class? Pin
benax.von19-May-04 23:18
memberbenax.von19-May-04 23:18 

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