CGrid Control






4.14/5 (17 votes)
An article on a grid control built with Windows API. Also includes an MFC class

Introduction
This article presents a Grid control which is built with Windows API. It also has an MFC class.
Background
You can get many grid controls from the Internet. Maybe some of them are free and others are not. Grid is a useful control to show or edit data. The grid control presented in this article support up to 65536 rows and 256 columns. It also supports text edit and boolean type edit.
Using the Code
To use the Grid control in SDK project, grid_lib
project must be compiled. And after that, a header file must be included.
#include "grid_lib\grid_lib.h"
Next, initialize the Grid and create a window handle of the Grid.
InitGrid(::GetModuleHandle(NULL));
hWndGrid = CreateGrid(WS_VISIBLE | WS_CHILD, 0, 0, 0, 0, hWnd, ::GetModuleHandle(NULL));
To use the Grid control in MFC project, grid_lib
project must be compiled. And after that, a header file must be included.
#include "MFCGrid.h"
After creating an instance of grid control, use GetGrid()
function to get the CGrid*
pointer. The CGrid
control supports the following:
CellFromPoint
ClearCell
Draw
Get
background brushGet
/set
background colorGet
/set
fix cell background colorGet
/set
fix cell board colorGet
/set
focus cell board colorGet
/set
selected cell background colorGet
/set
sheet background colorGet
/set
column countGet
/set row countGet
/set
fix row countGet
/set
fix column countGet
/set
fontGetMergeInfo
Get
/set
row heightGet
/set
column width- Insert/remove row
- Insert/remove column
- Merge/split cells
Get
/set
celltext
Get
/set
cellchar
Get
/set
celluchar
Get
/set
cellshort
Get
/set
cellushort
Get
/set
cellint
Get
/set
celluint
Get
/set
celllong
Get
/set
cellulong
Get
/set
cellfloat
Get
/set
celldouble
Get
/set
cellbool
History
- 29/05/2007: First release