Click here to Skip to main content
15,867,568 members
Articles / Desktop Programming / MFC

SuperGrid - Yet Another listview control

Rate me:
Please Sign up or sign in to vote.
4.77/5 (98 votes)
8 Dec 1999CPOL3 min read 1M   11.4K   345   192
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 ;-).

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)


Written By
Switzerland Switzerland
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionCool control but why?? Pin
mschuckmann5-May-03 13:52
mschuckmann5-May-03 13:52 
AnswerRe: Cool control but why?? Pin
tbrammer16-Dec-03 3:36
professionaltbrammer16-Dec-03 3:36 
Generalvb.net version of supergrid Pin
pradipta2-May-03 21:20
pradipta2-May-03 21:20 
GeneralRe: vb.net version of supergrid Pin
Thomas Caudal20-Jun-03 2:32
Thomas Caudal20-Jun-03 2:32 
GeneralUpdateData or How to update record Pin
Michael_Russia25-Apr-03 8:45
sussMichael_Russia25-Apr-03 8:45 
GeneralRe: UpdateData or How to update record Pin
sarangks4-Jun-03 22:30
sarangks4-Jun-03 22:30 
GeneralRe: UpdateData or How to update record Pin
Member 124060524-Sep-03 2:14
Member 124060524-Sep-03 2:14 
GeneralRe: UpdateData or How to update record Pin
EPulse5-Dec-03 17:49
EPulse5-Dec-03 17:49 
GeneralCapturing OnCheck Event Pin
Chok Han10-Apr-03 17:24
Chok Han10-Apr-03 17:24 
GeneralRe: Capturing OnCheck Event Pin
Herusetiyadi8-Jun-13 3:11
Herusetiyadi8-Jun-13 3:11 
GeneralVery Tasty Pin
Member 1802593-Apr-03 20:02
Member 1802593-Apr-03 20:02 
GeneralThe source file is not up to date Pin
djburt1-Apr-03 8:33
djburt1-Apr-03 8:33 
GeneralCollaps bug? :-O Pin
Mr Scotty25-Feb-03 23:00
Mr Scotty25-Feb-03 23:00 
QuestionHow to display the tree in the second column? Pin
miksh17-Feb-03 20:54
miksh17-Feb-03 20:54 
QuestionUsing VB.NET - what to do to get the DLL? Pin
John Wadleigh17-Feb-03 4:10
John Wadleigh17-Feb-03 4:10 
QuestionSubItems supporting Images??? Pin
schnitzele11-Feb-03 3:41
schnitzele11-Feb-03 3:41 
AnswerRe: SubItems supporting Images??? Pin
Member 3059834-Dec-03 23:53
Member 3059834-Dec-03 23:53 
GeneralHandle NM_DBLCLK in Dialog Pin
3-Feb-03 3:02
suss3-Feb-03 3:02 
GeneralBug on CSuperGrid::SelectNode - The *Bug* and the *Solution*. Pin
C. Augusto Proiete30-Jan-03 10:13
C. Augusto Proiete30-Jan-03 10:13 
GeneralRe: Bug on CSuperGrid::SelectNode - The *Bug* and the *Solution*. Pin
Roshmon2-Jul-03 21:08
Roshmon2-Jul-03 21:08 
GeneralRe: Bug on CSuperGrid::SelectNode - The *Bug* and the *Solution*. Pin
C. Augusto Proiete17-Sep-03 17:49
C. Augusto Proiete17-Sep-03 17:49 
QuestionText invisible when using it in Dialog? Pin
Martijn22-Jan-03 9:22
Martijn22-Jan-03 9:22 
AnswerRe: Text invisible when using it in Dialog? Pin
Miguel Lopes5-Feb-03 11:50
Miguel Lopes5-Feb-03 11:50 
GeneralRe: Text invisible when using it in Dialog? Pin
Martijn5-Feb-03 12:27
Martijn5-Feb-03 12:27 
GeneralCongratulations! Pin
C. Augusto Proiete30-Dec-02 8:04
C. Augusto Proiete30-Dec-02 8:04 

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.