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.

the tree are blinking and freeeze for many times when I trying to add 100 000 nodes ... I think that this can make better ... I remember one VirtualTreeView in C Builder that load 100 000 nodes for 2 seconds may we can take an idea from this ... If i have time I will try to improve it ...

I am new in Visual C++. I use the Microsoft Visual C++ Version 6.0 and i have a small problem with the list control.
I cannot find a way (or i do not understand) how i could change the letter in specific lines with bolt and change at the same lines the text color and the background color.
Until now i am using the report style with a grid and i am load the data from a database.
I hope someone helps me as soon as possible.
Thans in advabce for your time.
Best regards,
Konstantinos.

This is a good ariticle,thanks for the author.
I used it,very nice to extend,simple interface,detailed example.I use it inherited from my own listctrl,to just make my list ctrl has the tree behavior.
thanks again.

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.

I want to realize the directory tree like the listview.Beacuse I want to realize the directory tree, I just know how to realize the tree not other function code.But I can't to understand where to construct the tree in the project.

I want to be able to sort list by clicking on a column header. It should sort depending on column data type.
I am beginner in C++..
But I like control, a lot. It reminds me of Delphi control I like (ELTreeView from LMD Tools)

Hi,
first I want to thanks the developer. you saved me a lot of time.
I have worked a lot on this listctrl but I just couldn't replace two raws in
the list. I added two buttons for moving a selected raw Up and Down.

I'm popping up a dialog containing only a CComboBoxEx in response to a column RClick. The last ComboboxEx list item text (as soon as DoModal on dialog) appears in all supergrid cells (in created rows) that have not been initialized with text or have been initialized with _T(""). The reason for the popup (rather than using a cell Listbox) is for UI consistency with other cells which require more complex dialogs.
The workaround to this is to initialize all column cells with _T(" ") at row creation.
If anyone wants to look into this, let me know and I will put together a simple test case.

I have been using this control for a while and it works nicely once you understand it, but it seems there is no way to sort on the root items. Try it in the example. You'll see that the top most root items don't sort. Only the children do.

I added some code to try to fix this problem, by calling CListView::SortItems() and then swapping the corresponding CTreeItem pointers among each LV_ITEM in the view. It does sort, but the children don't show correctly when the +/- signs are clicked.

I'm sorry to say - but while I'm sure you've worked a lot on it, and the UI looks great -,

IT IS EXTREMELY HARD TO USE IN REAL APPS.

In fact, it made my life a nightmare to use (I've worked on a project that used this class, and needed to customize the UI).

I would suggest you provide a MUCH simpler interface . The current one is way too big, hard to understand, and error prone.

Especially, what really killed me, was the fact that when the user clicks a "Collapse" button, my list items are DELETED. Thus, I needed to create an extra wrapper to somewhere hold references to their text.
Then, I had to create a custom mechanism for uniquely identifying an item in such a Super Grid (since the item's index wouldn't work)

>I'm sorry to say
hey don't be
>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...
>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
>Then, I had to create a custom mechanism for uniquely identifying an item
I hope your nightmares are over .