5,699,997 members and growing! (24,292 online)
Email Password   helpLost your password?
Desktop Development » Combo & List Boxes » General     Beginner

SuperGrid - Yet Another listview control

By Allan Nielsen

A combination list control and tree control with checkbox capability
VC6, C++Windows, Win2K, MFC, VS6, Visual Studio, Dev

Posted: 26 Nov 1999
Updated: 8 Dec 1999
Views: 364,511
Bookmarked: 203 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
151 votes for this Article.
Popularity: 10.11 Rating: 4.64 out of 5
5 votes, 6.4%
1
0 votes, 0.0%
2
4 votes, 5.1%
3
9 votes, 11.5%
4
60 votes, 76.9%
5

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 ;-).

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Allan Nielsen



Location: Switzerland Switzerland

Other popular Combo & List Boxes articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 25 of 182 (Total in Forum: 182) (Refresh)FirstPrevNext
QuestionDialog based application [modified]memberkrishnanand4:16 2 Jul '08  
QuestionColumn problem when dynamic settingmemberEva ranee0:50 18 Sep '07  
QuestionMultiple column sortinmembersharathgowda3:35 10 Jul '07  
GeneralIt looks so good.memberN1i2c3k20:31 8 Jun '07  
QuestionI need some help about delete itemsmemberStarsrain16:37 4 Apr '07  
GeneralDo you have a VB OO compatible version or OCX ?memberMCMikey698:40 21 Mar '07  
GeneralBug in check boxesmember_faraz1:48 12 Mar '07  
GeneralRe: Bug in check boxesmember_faraz2:33 12 Mar '07  
Generalhow do you implement it ?membershuaicarr19:24 25 Jan '07  
QuestionNested List-Control with Column-Headers ?memberwebspektive5:34 7 Dec '06  
GeneralReally useful but is it possible? [modified]membercrazydave225:27 23 Oct '06  
General1. Does anybody know how to implement Multiselection ( Rows ) into this fine piece of code?memberhawonjeon21:26 10 Oct '06  
GeneralRe: 1. Does anybody know how to implement Multiselection ( Rows ) into this fine piece of code?membertangshengye3:24 29 Oct '08  
Generalproblem with add 100 000 nodesmembernikomsj4:16 14 Sep '06  
Generalbugmemberkingship7:32 9 Aug '06  
GeneralNeed Some helpmemberkonstantinos_10001:42 28 Jul '06  
Generalvery goodmemberbishanhu4:37 6 Jun '06  
Generalwrong version in the download linkmemberbanbanyy2:39 8 Feb '06  
Generalany one immplemented LVS_EX_HEADERDRAGDROP to this??memberkumar_anand0:19 9 Dec '05  
GeneralHow to use SetItemData?memberHarveyLiu18:49 14 Aug '05  
AnswerRe: How to use SetItemData?memberDanila Korablin6:34 25 Jun '07  
GeneralHow to change Parent ItemmemberTu Tran14:52 15 Jul '05  
Generalset check box after iconsmembersammmmmy0:55 8 Jul '05  
GeneralRe: set check box after iconsmembersammmmmy1:06 8 Jul '05  
Generalvery good,Thaknsmemberhpxs18:08 21 Jun '05  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 8 Dec 1999
Editor: Chris Maunder
Copyright 1999 by Allan Nielsen
Everything else Copyright © CodeProject, 1999-2008
Web16 | Advertise on the Code Project