Preface

This grid is the work of thousands of hours of squinting at pixels, hunting memory leaks, adding new features, fixing new bugs and beating the code by force of will into a form that is as feature rich and useable as something of this form can be. Dozens of developers from all over the world have contributed fixes, improvements and suggestions over the 4 years that the grid has been growing, and there is still no end in sight. Most of the fixes have been sent in by readers so I'm trusting that they have done sufficient testing.

Release 2.27 is a minor update of 2.26 for Visual Studio 2010 and includes a couple of minor bug fixes. Version 2.26 has is still available for download above.

After pushing the CListCtrl to its limits in trying to display and edit tabulated data I decided what was really needed was a dedicated grid control. I started writing my own grid control from scratch but decided to save time by modifying Joe Willcoxson's free WorldCom grid control at http://users.aol.com/chinajoe/wcmfclib.html. I tore apart his code and rebuilt it from the ground up in order to get it to do all the things I needed. The code has gone through so many modifications that I'm not sure if there is even a single original line of code. In any case Joe's code was a great framework on which to build.

The project started out as a simple clean up but very quickly ballooned into a bit of a nightmare as I kept finding new features that I felt just had to go into it. It has not been tested exhaustively - but I'm fairly confident that it won't fall over too badly :). Joe was kind enough to allow me to release the source with no strings attached (since it is based on his code) but since the project was such a marathon I am placing a couple of very minor conditions on the use of this code:

This code may be used in compiled form in any way you desire (including commercial use). The code may be redistributed unmodified by any means providing it is not sold for profit without the authors written consent, and providing that this notice and the authors name and all copyright notices remains intact. However, this file and the accompanying source code may not be hosted on a website or bulletin board without the authors written permission.

This software is provided "as is" without express or implied warranty. Use it at your own risk!

Whilst I have made every effort to remove any undesirable "features", I cannot be held responsible if it causes any damage or loss of time or data.

Hopefully that isn't too much to ask considering the amount of work that went into this. If you do use it in a commercial application then please send me an email letting me know. There's no point in me releasing and maintaining/upgrading this thing if no one is gonna use it.

The control features:

Cell selection using the mouse, with optional Control and Shift key combinations. Selection can be disabled.

Row and Column resizing. Sizing can be disabled for row, columns or both.

Auto row or column sizing when dividers are double-clicked.

Any number of fixed rows and columns.

Individual cells can have separate text and background colours.

Individual cells can have separate fonts.

Individual cells can be marked "Read-Only", or have their modification status set and checked.

In place editing of cell contents. If a character key is pressed while a cell has focus, editing will start on that cell, and the arrow keys will allow navigation to other keys. If the current focus cell is clicked on, editing will start and the arrow keys will move the carat inside the edit control. Editing can be disabled.

Support for Microsoft intellimouse.

Optional grid lines.

Images in any cell

"Virtual" mode for large datasets

Full printing support, for either a Doc/View environment (inc Print preview) or a standalone dialog based app (no print preview).

Optional "List mode", including full row selection, single row selection, and sort on column header click.

Numerous virtual functions to allow this control to be extended very easily.

Unicode support.

WinCE support

Titletips for cells that are too small to display their data.

Hidden rows and columns

Compiles under VC 4.2, 5.0, 6.0 and under the CE toolkit version 2.0 and 3.0

The sample project demonstrates most of the features of the grid control.

Grid control OLE drag and drop target. Only necessary if you don't define GRIDCONTROL_NO_DRAGDROP in gridctrl.h

Titletip.cpp, Titletip.h

Titletips for cells, from Zafir Anjum. Only necessary if you don't define GRIDCONTROL_NO_TITLETIPS in gridctrl.h

Structure

The grid is based on a framework (the CGridCtrl object) that organises and controls a collection of cells (CGridBaseCell) that contain the data, perform operations such as drawing, and handle methods such as button clicks. The grid object itself handles events such as button clicks before the cells get a chance, and will pass on certain mouse messages if it considers it necessary. The grid also contains a drag and drop target (CGridDropTarget) that is registered to handle drop notifications, and there is also a title tip object (CTitleTip) that displays the contents of cells when the physical dimensions of a cell are insufficient to display its' contents in their entirety.

The grid cells can be of any type as long as the class is derived from CGridBaseCell. Included with the package is a CGridCell class that handles basic data storage and editing. Extensions such as the CGridCellCombo and CGridURLCell class demonstrate how to create your own cell classes.

There are two main types of cell - fixed and non-fixed. Fixed cells are typically on the left and top of the grid and do not move when the grid is scrolled. Typically these contain column and row headings and are not editable. Non fixed cells make up the "interior" of the grid and can be edited and selected.

Default values for various properties of the grid are stored in CGridDefaultCell objects. There are currently 4 of these objects per grid - one each to hold default values for the non-fixed cells, fixed columns, foxed rows, and cells that are both fixed rows and columns cells. Thus in order to set a default property for the grid, use CGridCtrL::GetDefaultCell to get the default cell implementation you are after, then set it's values directly.

Cells hold their property values explicitely, except for the font property. Each cell holds a pointer to a font structure, and this pointer is only allocated and used if you set that cell's font to a non-default value.

The grid also has a virtual mode that stops the grid from actually creating cells, and allows you to specify either a callback funtion or message handler that the grid will call each time it needs information on a cell. This saves enourmously on memory at the expense of slightly decreased performance. There is a GVN_ODCACHEHINT message that is sent to the grid's parent that will help you cache data in preparation for the grid's cell info requests.

Grid cells are stored row-by-row, so all operations on large numbers of cells should be done row-by-row as well.

The underlying class of the grid control is CGridCtrl which is derived from CWnd. To use it, either use the MS Visual C++ dialog editor to place a custom control on a dialog, and enter "MFCGridCtrl" (no quotes) as the Class name. To subclass the control using the DDX mechanism (this will be done by default by the ClassWizard) use the DDX_GridControl function instead of the DDX_Control function (just manually change the ClassWizard entry). This ensures your control is correctly registered as a drop target and avoids some weird win95 issues.

Alternatively you can use CGridCtrl::Create:

CGridCtrl grid;
grid.Create(rect, pParentWnd, nID);

where rect is the dimensions, pParentWnd is the parent window, and nID is the id.

Virtual mode allows you to use the grid to display large amounts of data without requiring the grid to actually store this data. In Virtual Mode, no cells are created and no data is stored other than the widths and heights of columns and rows.

Since the data is not stored by the grid, the grid must have some way of asking the application to supply it with data. This is done either by either registering a callback function with the grid, or by having the parent handle a GVN_GETDISPINFO notification.

void SetVirtualMode(BOOL bVirtual)

Places the grid in or out of virtual mode.

BOOL GetVirtualMode()

Returns TRUE if the grid is in virtual mode.

void SetCallbackFunc(GRIDCALLBACK pCallback, <br /> LPARAM lParam)

Sets the callback function for when the grid is in virtual mode.

GRIDCALLBACK GetCallbackFunc()

Returns the callback function when the grid is in virtual mode.

If no callback function is specified then the grid will send a GVN_GETDISPINFO message to it's parent. A GV_DISPINFO structure part of this notification, and looks like:

Obviously it's nice to have a hint as to what sort of data the grid will be asking for in order to allow caching, so the grid sends out a GVN_ODCACHEHINT message before displaying a page of cells. A GV_CACHEHINT structure is sent as part of this message and looks like:

You can use SetCallbackFunc to set a callback function that the grid will call directly instead of sending a GVN_GETDISPINFO message. A GVN_ODCACHEHINT message will still be send if a callback is used.

Sets the current image list for the grid. The control only takes a copy of the pointer to the image list, not a copy of the list itself.

CImageList* GetImageList()

Gets the current image list for the grid.

void SetGridLines(int nWhichLines = GVL_BOTH)

Sets which (if any) gridlines are displayed. See here for possible values.

int GetGridLines()

Gets which (if any) gridlines are displayed. See here for possible return values.

void SetEditable(BOOL bEditable = TRUE)

Sets if the grid is editable.

BOOL IsEditable()

Gets whether or not the grid is editable.

void SetListMode(BOOL bEnableListMode = TRUE)

Sets the grid into (or out of) List mode. When the grid is in list mode, full row selection is enabled and clicking on the column header will sort the grid by rows.

BOOL GetListMode()

Get whether or not the grid is in list mode.

void SetSingleRowSelection(BOOL bSing = TRUE)

Sets the grid into (or out of) Single row selection mode. This mode is only effective when in ListMode. When in this mode, only a single row at a time can be selected, so the grid behaves somewhat like a multicolumn listbox.

BOOL GetSingleRowSelection()

Get whether or not the grid is in single row selection mode.

void SetSingleColSelection(BOOL bSing = TRUE)

Sets the grid into (or out of) Single column selection mode. When in this mode, only a single column at a time can be selected.

BOOL GetSingleColSelection()

Get whether or not the grid is in single column selection mode.

void EnableSelection(BOOL bEnable = TRUE)

Sets whether or not the grid cells can be selected.

BOOL IsSelectable()

Get whether or not grid cells are selectable.

void SetFixedRowSelection(BOOL bSelect)

Set whether or not clicking on a fixed row selects the cells next to it.

BOOL GetFixedRowSelection()

Get whether or not clicking on a fixed row selects the cells next to it.

void SetFixedColumnSelection(BOOL bSelect)

Set whether or not clicking on a fixed column selects the cells underneath.

BOOL GetFixedColumnSelection()

Get whether or not clicking on a fixed column selects the cells underneath.

void EnableDragAndDrop(BOOL bAllow = TRUE)

Sets whether drag and drop is enabled.

BOOL GetDragAndDrop()

Get whether drag and drop is allowed.

void SetRowResize(BOOL bResize = TRUE)

Sets whether or not rows can be resized.

BOOL GetRowResize()

Gets whether or not rows can be resized.

void SetColumnResize(BOOL bResize = TRUE)

Sets whether or not columns can be resized.

BOOL GetColumnResize()

Gets whether or not columns can be resized.

void SetHandleTabKey(BOOL bHandleTab = TRUE)

Sets whether or not the TAB key is used to move the cell selection.

BOOL GetHandleTabKey()

Gets whether or not the TAB key is used to move the cell selection.

void SetDoubleBuffering(BOOL bBuffer = TRUE)

Sets whether or not double buffering is used when painting (avoids flicker).

BOOL GetDoubleBuffering()

Gets whether or not double buffering is used when painting.

void EnableTitleTips(BOOL bEnable = TRUE)

Sets whether or not titletips are used.

BOOL GetTitleTips()

Gets whether or not titletips are used.

void SetTrackFocusCell(BOOL bTrack)

Sets whether or not the fixed cells on the same row/column as the current focus cell are highlighted with a sunken border

BOOL GetTrackFocusCell()

Gets whether or not the fixed cells on the same row/column as the current focus cell are highlighted with a sunken border

void SetFrameFocusCell(BOOL bFrame)

Sets whether or not the cell with the focus is highlighted with a framed border

BOOL GetFrameFocusCell()

Gets whether or not the focus cell is highlighted with a framed border

void SetAutoSizeStyle(int nStyle = GVS_BOTH)

Sets how the auto-sizing should be performed. GVS_BOTH = use fixed and non fixed cells; GVS_HEADER = use only the fixed cells; GVS_DATA = use only non-fixed cells.

int GetAutoSizeStyle()

Gets how the auto-sizing should be performed

void EnableHiddenColUnhide(BOOL bEnable = TRUE)

Sets whether or not hidden (0-width) columns can be unhidden by the user resizing the column.

BOOL GetHiddenColUnhide()

Gets whether or not hidden (0-width) columns can be unhidden by the user resizing the column.

void EnableHiddenRowUnhide(BOOL bEnable = TRUE)

Sets whether or not hidden (0-height) rows can be unhidden by the user resizing the row.

BOOL GetHiddenRowUnhide()

Gets whether or not hidden (0-height) rows can be unhidden by the user resizing the row.

Sets the background colour of the control (the area outside fixed and non-fixed cells).

COLORREF GetGridBkColor()

Gets the background colour of the control.

void SetGridLineColor(COLORREF clr)

Sets the colour of the gridlines.

COLORREF GetGridLineColor()

Gets the colour of the grid lines.

COLORREF GetTitleTipBackClr()

Gets the background colour of the titletips.

void SetTitleTipBackClr(COLORREF clr = CLR_DEFAULT)

Sets the background colour of the titletips.

COLORREF GetTitleTipTextClr()

Gets the text colour of the titletips.

void SetTitleTipTextClr(COLORREF clr = CLR_DEFAULT)

Sets the text colour of the titletips.

The following functions are no longer supported. You should use GetDefaultCell to get the default cell implementation for the cell type you are intererested in, then set that cell's properties directly. If a given cell has default values set, then it will use the values in the default cell implementation that matches that cell type.

void SetTextColor(COLORREF clr)

Sets the colour of the text in non-fixed cells.

COLORREF GetTextColor()

Gets the colour of the text in non-fixed cells.

void SetTextBkColor(COLORREF clr)

Sets the background colour of the non-fixed cells.

COLORREF GetTextBkColor()

Gets the background colour of the non-fixed cells.

void SetFixedTextColor(COLORREF clr)

Sets the colour of the text in fixed cells.

COLORREF GetFixedTextColor()

Gets the colour of the text in fixed cells.

void SetFixedBkColor(COLORREF clr)

Sets the background colour of the fixed cells.

COLORREF GetFixedBkColor()

Gets the background colour of the fixed cells.

void SetBkColor(COLORREF clr)

Sets the background colour of the control (the area outside fixed and non-fixed cells).

Gets a pointer to the default cell implementation for the desired cell type. bFixedRow and bFixedCol specify whether the cell is fixed (in row, column or both) or unfixed. Use this to set default properties for the grid. Actual cells in the grid have their values set as default values when they are first created. They will use GetDefaultCell to query the grids default cell properties and use these values for drawing themselves.

Inserts a column at the position given by nCol, or at the end of all columns if nCol is < 0. strHeading is the column heading and nFormat the format. Returns the position of the inserted column.

int InsertRow(LPCTSTR strHeading, <br /> int nRow = -1)

Inserts a row at the position given by nRow, or at the end of all rows if nRow is < 0. strHeading is the row heading. The format of each cell in the row will be that of the cell in the first row of the same column. Returns the position of the inserted row.

BOOL DeleteColumn(int nColumn)

Deletes column "nColumn", return TRUE on success.

BOOL DeleteRow(int nRow)

Deletes row "nRow", return TRUE on success.

BOOL DeleteAllItems()

Deletes all rows and contents in the grid.

BOOL DeleteNonFixedRows()

Deletes all non-fixed rows in the grid.

BOOL AutoSizeRow(int nRow, BOOL bResetScroll=TRUE)

Auto sizes the row to the size of the largest item. If bResetScroll is TRUE then the scroll bars will be reset.

Sets whether or not rows are sorted on column header clicks in ListMode.

BOOL GetHeaderSort()

Gets whether or not rows are sorted on column header clicks in ListMode.

SetSortColumn(int nCol

Sets the index of the currently sorted column.

int GetSortColumn()

Gets the index of the currently sorted column.

void SetSortAscending(BOOL bAscending)

Sets whether the current sort column is sorted ascending.

BOOL GetSortAscending()

Gets whether the current sort column is sorted ascending.

BOOL SortTextItems(int nCol, BOOL bAscending, <br /> LPARAM data = 0)

Sorts the grid on the given column based on cell text. Returns TRUE on success.

BOOL SortItems(int nCol, BOOL bAscending, <br /> LPARAM data = 0)

Sorts the grid on the given column based using the current comparison function. If no function has been specified then the rows are sorted by text. Returns TRUE on success. See also SetCompareFunction()

void SetCompareFunction(PFNLVCOMPARE pfnCompare)

Sets the callback function that will be used to sort the grid rows. See below for more details.

void SetVirtualCompare(PVIRTUALCOMPARE VirtualCompare)

Sets the callback function that will be used to sort the grid rows in virtual mode. See below for more details.

Sorts the grid on the given column using the supplied compare function pfnCompare. See CListCtrl::SortItems for information in the form of this function. Returns TRUE on success.

Sorting is achieved by calling one of the variants of SortItems, SortTextItems, or by the user clicking on a column header when in list mode.

The simplest way to handle sorting is to set the function that will be used in cell comparisons (by calling SetCompareFunction and/or SetVirtualCompare) and then calling SortItems(int nCol, BOOL bAscending, LPARAM data = 0). nCol is the column to sort, bAscending sets whether the sort is in ascending or descending order, and data is application specific data that will be passed to the comparison function.

The comparison function must be a global or static function with the form

lParam1 and lParam2 will be CGridCellBase pointers, and lParamSort will be the application specific data you pass into the SortItems function as the data parameter. The function must return -1 if the first cell contains a value less than the second cell; 0 if they are equal, otherwise 1.

These sort by Text value and by numeric value (using itoa respectively. To set the comparison function for the grid simply call:

m_Grid.SetCompareFunction(CGridCtrl::pfnCellNumericCompare);

If the comparison function is set as NULL, CGridCtrl::pfnCellTextCompare will be used by default.

Sorting in Virtual mode requires you provide a function with the signature bool (*PVIRTUALCOMPARE)(int, int); to the function SetVirtualCompare. Needless to say this function will have to be optimised if you are trying to sort large amounts of data.

The CGridCellBase class

This class is the base class for all grid cell classes, and holds the information for each cell. The class also defines a number of methods that are called by the grid itself, such as drawing and printing. Almost all methods and functions are virtual and this class is not designed to be used directly - rather it should be derived from. The default class CGridCell is derived from CGridCellBase and is used by the Grid control as the default cell class.

This makes customising cells extremely simple. To install a new type of derived class for your grid cells, you can either override CGridCtrl::CreateCell and create your derived CGridCellBase cells, or you can use CGridCtrl::SetCellType and CGridCtrl::SetDeafaultCellType to automate this.

Simply create a new cell class derived from CGridCellBase or CGridCell (eg. CMyGridCell), and then replace the cells in the grid by calling

GVN_BEGINDRAG // Sent when dragging starts
GVN_BEGINLABELEDIT // Sent when inplace editing starts
GVN_ENDLABELEDIT // Sent when inplace editing stops
GVN_SELCHANGING // Sent just before cell selection changes
GVN_SELCHANGED // Sent after cell selection changes
GVN_GETDISPINFO // A request for cell information when the grid is
// in virtual mode
GVN_ODCACHEHINT // Cache hint when in virtual mode

These messages are exactly the same as their LVN_... counterparts, except they use an NM_GRIDVIEW structure:

There are several ways you can control whether or not cells can be edited, or indeed whether or not changes to cells should be accepted or rejected.

The simplest is to use SetEditable(BOOL). This determines whether or not the cells in the grid can be edited. Finer scale control can be achieved by setting the GVIS_READONLY flag on a particular cell:

Further control can be achieved by handling the GVN_BEGINLABELEDIT message. If the return value for this message is < 0 then the edit attempt for the given cell will be rejected and the cell will be treated as read-only. This message is sent each time an edit attempt is made on a cell.

The final validation method you can use is to derive a new CGridCellBase class and override the ValidateEdit method. If this method returns TRUE then the edit is accepted, otherwise the edit is rejected.

First release version. Progressed from being a basic grid based on the original WorldCom Grid control written by Joe Willcoxson (mailto:chinajoe@aol.com, http://users.aol.com/chinajoe) to something a little more feature rich. Rewritten so many times I doubt there is a single line of Joe's code left. Many, many, MANY people sent in bug reports and fixes. Thank you all.

2.016 Feb 2000

Rewritten to make the grid more object oriented, in that the CGridCell class now takes care of cell-specific tasks. This makes the code more robust, but more importantly it allows the simple insertion of other types of cells. Most of the bugs in the previous version have been fixed, especially the "ExpandToFit" functions and the cell selection/focus. I expect I've introduced a bunch more :)

Ken Bertelson, Aqiruse and Chris MaunderTitletips now use cell colorMore attribute accessor functions, plus previously private functions now publicAdditions for virtual CGridCell support of embedded tree & cell buttons implementationOptional WYSIWYG printingAwareness of hidden (0 width/height) rows and columns for key movements, cut, copy, paste, and autosizingCGridCell can make title tips display any text rather than cell text onlyMinor vis bug fixesCGridCtrl now works with CGridCellBase instead of CGridCell. This is a taste of things to come.

SetModified bug in SetItem (Keith Worden)ifdef around SetItemTextFmt corrected for win32Save() bug fixed (row 0 saved twice)GetTopleftNonFixedCell, GetUnobstructedNonFixedCellRange and GetVisibleNonFixedCellRange have optional parameter to force recalc.added virtual ValidateEdit.if the return value from the SendMessage operation for GVN_ENDLABELEDIT or GVN_BEGINLABELEDIT is < 0 then the edit, or the attempt to edit (respectively) is rejected.Added GetEditWnd to CGridCellBaseFixed the paste bug for cells being edited (Gary Lyben).GVN_SELCHANGING/GVN_SELCHANGED messages now sent correctlyOnRButtonUp was not handling clicks on fixed cells correctlySB_ENDSCROLL message now sent on keypress initiated scrollGetCellTextExtent bug fixed (Elco)SetSelectedRange inefficiency fixed by huangchaoyi (ahaa007@263.net)DT_NOCLIP removed from CGridCellBase::PaintSetRowCount returns correct value on OOM condition (asigal@hotmail.com)Bug when editing using Japanese characters fixed (Michael Dunn)Fixed columns and rows printed correctly (fletch - untested)Added the "ClearCells" functionAdded the "SetCompareFunction" function and revamped sortingAdded "GetEditWnd()" to CGridCellBaseAdded "GetTipText" to CGridCellBase

2.2322 July 2001

Save/Load now take optional second parameter to set separator characterWhen in list mode, fixed columns are no longer editableCombobox grid cells now auto-resize correctlyCells are printed using printer font, not screen font (Laura Michaels)ExpandLastColumn fixed (Jim Arnold)When entering DBCS chars into cells the first char was being lost (KiteFly)EnsureVisible no longer steals the focus (Damir)Ctrl+mouse-click no longer puts a cell into edit mode (useful for unselecting) (Richard Bouwman)SetModified/GetModified wasn't handling the first row or column (Ivan Melnychuk)GetCellFromPt Fixed cell check bug fixed (Jim Arnold)Plus a few nips and tucks (Simon Hughes and others)SetItem bug when setting select state fixed (Mik)ComboCell draw error (Joanna Sadler)NULL pointer reference bug fixed in GetTextRect (Jim Arnold)Drag/Drop handler functions now virtualPrint() now accepts a pointer to a CPrintDialog object, so you can use your own print dialog when printing (Andrew Truckle)Cell drawing now uses CGridCellBase::GetTextExtent, which simplifies drawing logic for derived classes that embed controls. See the Checkbox cell for more infoValidateAndModifyCellContents no longer modifies read-only cellsDrag and drop can now start from read-only cells (Jim Arnold)ResetScrollBars fixed (not fully checked though) - Paul RunstedlerEraseBkgnd vis problem fixed (Sean McKinnon)ExpandLastColumn, ExpandRowsToFit and ExpandColumnsToFit now respect hidden rows/columns.Thanks to Podsypalnikov Eugen for the DateTimeCtrl cell type.

2.244 July 2002

Corrected compile errors in Visual C++ .NETAdded CGridCellNumeric cell type - Andrew TruckleSelecting cells using the keyboard sends GVN_SELCHANG* messages to the parent - Arthur Westerman/Scot BrenneckeWhen printing, the cells now use the grid's default cell colour unless otherwise specifiedTabbing over hidden rows now works correctlyEnsureVisible bug where NULL pFocusWnd was being used fixed - Patrick DellEraClient border now shows at startup even if size if cells is smaller than size of grid client areaCGridCellBase members pure virtual - Scot BrenneckeMinor code cleanups and clarificationsMinor speed improvements (eg Optimised OnDraw for invisible cells)Pasted cells now set as selectedClicking on a fixed row no longer sets a focus cell (David Pritchard)DEL key now clears all selected cells

2.2513 Mar 2004

Minor changes so it will compile in VS.NET 2003 and WhidbeyFixed minor bug in EnsureVisible - Junlin XuChanged AfxGetInstanceHandle for AfxGetResourceHandle in RegisterWindowClassVarious changes thanks to Yogurt

License

Share

About the Author

Chris is the Co-founder, Administrator, Architect, Chief Editor and Shameless Hack who wrote and runs The Code Project. He's been programming since 1988 while pretending to be, in various guises, an astrophysicist, mathematician, physicist, hydrologist, geomorphologist, defence intelligence researcher and then, when all that got a bit rough on the nerves, a web developer. He is a Microsoft Visual C++ MVP both globally and for Canada locally.

His programming experience includes C/C++, C#, SQL, MFC, ASP, ASP.NET, and far, far too much FORTRAN. He has worked on PocketPCs, AIX mainframes, Sun workstations, and a CRAY YMP C90 behemoth but finds notebooks take up less desk space.

He dodges, he weaves, and he never gets enough sleep. He is kind to small animals.

Chris was born and bred in Australia but splits his time between Toronto and Melbourne, depending on the weather. For relaxation he is into road cycling, snowboarding, rock climbing, and storm chasing.

Comments and Discussions

Sorry I can't help you personally. But given the popularity and usefulness of this class and associated derivations it is a real shame that support has basically stopped. There clearly are issues with the classes, even in vs2005 under certain circumstances and for some of us it means we are kind of stuck in VC6 since it all works there.

I use the grid control in my hex editor (see http://www.hexedit.com[^]) and rebuilt with VS2003 and just recently VS2005 and had no problems. I am using 2.23 and have made lots of code changes so may have inadvertently fixed something (or "advertently" fixed it and forgot I did it).

I think Chris has enough on his plate without having to support something he wrote about 10 years ago. If you have any specific questions I may be able to help as I have a done a bit with the grid control oevr the years.

May be this issue I came accross many different libraries.
Code compiled for Vista will not simply work on XP. At least the follwing call will fail when run on XP:
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), ...)
This is a typical construct to get a font, and it does seem to be used this way in the grid control.
Hence try to build for XP (define WINVER=0x0501 for sp2, 0x0500 for generic XP). This was the only thing I needed to get the grid demo working in VS2008.

I am not sure where you got your 2.21 code from, but merged cells is not provided by default in GridCtrl. There is a seperate topic about the steps to implement merged cells. So maybe you are already using that class.

I would like to move the row from one row to another (reorder).
Can anyone tell me how to use the row reordering functions. I have used the DragRowMode(true) and AllowDragAndDrop(true) functions. But it is not working.