Skip to main content
Email Password   helpLost your password?

Sample Image

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

What�s new:

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.

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
GeneralIs there a way to edit the fields?
matt2000
10:03 23 Jan '09  
I'm looking for a way to group edit boxes with labels. I want to keep it simple. I could use a grid if I needed to, but this looks a lot cleaner.

Thanks!
Sign In·View Thread·PermaLink
QuestionDialog based application [modified]
krishnanand
4:16 2 Jul '08  
can u please explain me how to do the same in dialog based application?I have seen how to use the SuperGrid in dialog based application.But there is no check boxes available for items in dialog .Also I don't want the image icons.Can u please guide me how to achieve these things?

modified on Thursday, July 3, 2008 12:50 AM

Sign In·View Thread·PermaLink1.00/5
QuestionColumn problem when dynamic setting
Eva ranee
0:50 18 Sep '07  
before go into DrawItem(), I set the column with the item's length in LVN_GETDISPINFO process function OnGetDispInfo().
But there are some problem in DrawItem() that i can't find the reason.
[problem]
suppose i have follow data:
[+]ICON aaa
[+]ICON aaaa
[+]ICON aaaaa

DrawItem() first:
[+]ICON aaa

DrawItem() second:
[+]ICON aaa
___________a // before 'a', nothing

DrawItem() third:
[+]ICON aaa
___________a // before 'a', nothing
____________a // before 'a', nothing

have some idea? Thank you very much!



Follow the C++ technical

Sign In·View Thread·PermaLink2.00/5
QuestionMultiple column sortin
sharathgowda
3:35 10 Jul '07  
Hi

this is really fantastic control. I really like this.

Does this support multiple column sorting....

sharath b

"The world's biggest power is the youth and beauty of a woman."

Sign In·View Thread·PermaLink2.00/5
GeneralIt looks so good.
N1i2c3k
20:31 8 Jun '07  
It looks so good.Smile
Sign In·View Thread·PermaLink
QuestionI need some help about delete items
Starsrain
16:37 4 Apr '07  
my data is dynamic load from database,and i have carried it out only in the this

control.
my problem is i used the tree to control the data display in the list
tree control.On this way,i selchanged on the my tree control need display the data

in the list tree.at first,In my tree control selchange function i used the

deleteAll() function to delete the list tree all items and display the new

data.when i use the deleteall function the program will be intermitted. when i

used the DeleteAllItems() function to delete the list tree data,itself delete the

child node and display the child node function will be error.it display the data

not right.
like this:
+Root1
+Root2
+Root3
expend the Root1 then Root2 node will be delete and collapsed the Root1 it can't

delete itself children.

someone can help me or give me some suggestion,thanks
Sign In·View Thread·PermaLink1.33/5
GeneralDo you have a VB OO compatible version or OCX ?
MCMikey69
8:40 21 Mar '07  
Hi,

This is fantastic and just what I need. However, I'm using VB6 to write my app (loads of very good reasons for that which I won't go into). Do you have the control compiled as an OCX?

Cheers,
Mike May
Big Grin
Sign In·View Thread·PermaLink
GeneralBug in check boxes
_faraz
1:48 12 Mar '07  
Settting the check in a root level item does not work. For example the following code addition to the demo (InitializeGrid method) fails to set the check:


CItemInfo* lp = new CItemInfo();
lp->SetCheck(1);
lp->SetImage(4);

//add item text
lp->SetItemText(_T("Hello World"));
//add subitem text
lp->AddSubItemText(_T("Happy"));
....


I'm hunting this bug down now...

faraz
Sign In·View Thread·PermaLink1.50/5
GeneralRe: Bug in check boxes
_faraz
2:33 12 Mar '07  
To fix:

In CSuperGridCtrl::InsertRootItem(CItemInfo * lpInfo)

starting line 1488:

     CItemInfo* lp = GetData(pRoot);
     LV_ITEM lvItem;         
     lvItem.mask = LVIF_TEXT | LVIF_INDENT | LVIF_PARAM;
     CString strItem = lp->GetItemText();
     lvItem.pszText = strItem.GetBuffer(1);
     lvItem.iItem = GetItemCount();
     lvItem.lParam = (LPARAM)pRoot;
     lvItem.iIndent = 1;
     lvItem.iSubItem = 0;
     CListCtrl::InsertItem(&lvItem);
//Add this line in to let CListCtrl know about the check
     SetCheck(lvItem.iItem, lpInfo->GetCheck());

** Sometimes you know yourself something is a bad idea; follow your instinct Smile **

                    //yes I know..have to maintain to sets of checkstates here...
                    //one for listview statemask and one for CTreeItem..but its located here so no harm done
                    SetCheck(ht.iItem,!GetCheck(ht.iItem));
                    CItemInfo *pInfo = GetData(pItem);
                    pInfo->SetCheck(!pInfo->GetCheck());
Sign In·View Thread·PermaLink2.00/5
Generalhow do you implement it ?
shuaicarr
19:24 25 Jan '07  
First,i should say thanks to your effort.i take advantage of your control in my own project. but i think the interface is too large to manipulate.

would you give me a description on how do you combine "LIST" with "TREE" ?
the tree like thing is in the first column .when a tree subitem collapses ,the relevent items in list acts accordingly . how does it work ?
Sign In·View Thread·PermaLink1.67/5
QuestionNested List-Control with Column-Headers ?
webspektive
5:34 7 Dec '06  
Do you have any plans to implement nested List-Controls or Supergrids instead of 'normal' rows (like FlyGrid.Net or Sandgrid) ?
Sign In·View Thread·PermaLink1.00/5
GeneralReally useful but is it possible? [modified]
crazydave22
5:27 23 Oct '06  
Really useful but is it possible to add checkboxes to the SuperGrid in the dialog?

Do the controls work also in the dialog view?
Can't get them to work.

I would really appreciate anyones help?Sigh

I'm not daft, just stupid really!!!


-- modified at 8:12 Tuesday 24th October, 2006
Sign In·View Thread·PermaLink
General1. Does anybody know how to implement Multiselection ( Rows ) into this fine piece of code?
hawonjeon
21:26 10 Oct '06  
1. Does anybody know how to implement Multiselection ( Rows ) into this fine piece of code?

^^dssfasdfadsafasdfasdfasdfasdf

Sign In·View Thread·PermaLink1.00/5
GeneralRe: 1. Does anybody know how to implement Multiselection ( Rows ) into this fine piece of code?
tangshengye
3:24 29 Oct '08  
I am waiting for this as well. Laugh
Sign In·View Thread·PermaLink
Generalproblem with add 100 000 nodes
nikomsj
4:16 14 Sep '06  
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 ...

nik
Sign In·View Thread·PermaLink2.00/5
Generalbug
kingship
7:32 9 Aug '06  
my list like:
+ RootItem0
|-Item01
|-Item02
|-Item03
|-Item04
+ RootItem1
|-Item11
|-Item12
|-Item13
|-Item14
+ RootItem2
|-Item21
|-Item22
|-Item23
|-Item24

when collapse all rootitems,like:
+ RootItem0
+ RootItem1
+ RootItem2

run search("Item13",NULL)

result like:
+ RootItem0
|-Item11
|-Item12
|-Item13
|-Item14 <--(selected)
- RootItem1
+ RootItem2

at this time,click "+" or "-" some other errors can be found.



Sign In·View Thread·PermaLink1.00/5
GeneralNeed Some help
konstantinos_1000
1:42 28 Jul '06  
Dear All,

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.
Sign In·View Thread·PermaLink1.67/5
Generalvery good
bishanhu
4:37 6 Jun '06  
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.Smile
Sign In·View Thread·PermaLink2.00/5
Generalwrong version in the download link
banbanyy
2:39 8 Feb '06  
the version in this page is the one updated in 14 july(by history text) .it doesnot support the subitem'image.
the newest version is 4 dec. where is it ?
Sign In·View Thread·PermaLink2.67/5
Generalany one immplemented LVS_EX_HEADERDRAGDROP to this??
kumar_anand
0:19 9 Dec '05  
Hi;
If anyone has implemented this style,can u please post it here Big Grin??
Sign In·View Thread·PermaLink3.50/5
GeneralHow to use SetItemData?
HarveyLiu
18:49 14 Aug '05  
In listCtrl, we can use SetItemData to bound DWORD to every list item, but in this control, we can't do that, hope you can give those functions:SetItemData, GetItemData.;PLaugh
Sign In·View Thread·PermaLink3.67/5
AnswerRe: How to use SetItemData?
Danila Korablin
6:34 25 Jun '07  
To set data use:

//...
CItemInfo *lpItem=new CItemInfo();
int YourValue=123;
lpItem->SetItemText(_T("Note"));
lpItem->m_lParam=YourValue;
m_listItem.InsertRootItem(lpItem);
//...

To get data (For example in OnNMDblclkGrid()):

//...
CTreeItem* pSelItem=m_listItem.GetTreeItem(index);
int YourValue=(int)pSelItem->m_lpNodeInfo->m_lParam;
//...


Wormhole is the God divided by zero

Sign In·View Thread·PermaLink
GeneralHow to change Parent Item
Tu Tran
14:52 15 Jul '05  
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.


Sign In·View Thread·PermaLink1.67/5
Generalset check box after icons
sammmmmy
0:55 8 Jul '05  
How do i set the check boxes after the icons ?
Most of lists do that way.
THX
Sign In·View Thread·PermaLink1.50/5
GeneralRe: set check box after icons
sammmmmy
1:06 8 Jul '05  
Ooopss, I made a mistakae, i wanted to say check boxes before icons.
Thx
Sign In·View Thread·PermaLink1.40/5


Last Updated 8 Dec 1999 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2009