Click here to Skip to main content
13,591,049 members
Click here to Skip to main content
Add your own
alternative version


40 bookmarked
Posted 9 Jun 2004

CGridCtrl 1.5

, 17 Jun 2004
Rate this:
Please Sign up or sign in to vote.
This article presents a tiny grid control derived from the standard list control


This grid control is an advanced list control set to "Report" view that uses the custom-draw mechanism to paint itself. It provides a lot of extra features and the ability to easily add new ones.


Cell-level selection

Being a grid, it is divided into cells (not just rows). The cursor moves horizontally, too.

Multiple cell types

Cells are more than just blind text displayed; they can be edited. Currently, the following cell types are available:

  • Regular cell (blind text)

  • Edit box (Screenshot: Col1 has 5 edit box cells)

  • Combo box (Screenshot: Col2 has combo box cells)

  • Editable combo box (Screenshot: Col3 has editable combo cells)

  • Check box (Screenshot: Col5 has check box cells)

  • Custom edit (Ellipsis) (Screenshot: Col4 has ellipsis cell)

  • Separator (Screenshot: Row11 has separators)

New cell types can easily be added.

Inplace combo boxes with images

Combo box and Editable combo box cells, can display images when they are dropped down. When an item is edited, its new (text) value AND the corresponding image are applied.


You can select multiple cells simultaneously (see screenshot).


After editing a cell, its new value applies to the entire selection

Custom colors

The grid has a complex colouring system. First of all, it has a global color scheme applied by default to all its cells. Initially, this global color scheme uses the default Windows colors. Secondly, each cell can have overridden colors (and fonts).

Cell font-styles

Beside custom colors, each cell can have it's own font style. Currently is supported any combination of: bold, italic, underline and strikeout. For instance, in the screenshot, Col5 is BOLD + ITALIC, Col6 is UNDERLINE + STRIKEOUT.

Custom cell drawing

If you are not satisfied with the default behavior, you can easily custom draw any cell.

Incremental search

If you start typing a string, the selection jumps to the first cell that matches it.

Using the code

Being a list control, the grid is to be used the same way. First of all, insert some columns with InsertColumn. Then, insert items with InsertItem. Insert subitems using SetItem.


  1. Multi-selection is disabled by default. In order to enable, open the resource editor, select the list control, set it to report view and set "Single Selection" to false
  2. The grid will NOT work with LVS_EX_HEADERDRAGDROP style
  3. The grid was NOT tested with sorted columns. It might work, though...

For using the advanced features, you could take a look at the demo project... It's well commented.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Marius Negrutiu
Web Developer
Romania Romania
- C/C++ Programming
- Windows Device Driver programming (DDK)
- Low-level networking programmer (firewalls, routers, sniffers...)
- AutoCAD ObjectARX/DBX programming
- ADT Object Modeling Framework (OMF) programmer

You may also be interested in...

Comments and Discussions

QuestionWhere to set the cell style? Pin
hahakilokilo14-Jan-09 4:11
memberhahakilokilo14-Jan-09 4:11 
GeneralCreating problems Pin
chs8-07119-Sep-07 1:08
memberchs8-07119-Sep-07 1:08 
GeneralRe: Creating problems Pin
Member 1041681524-Oct-15 4:19
memberMember 1041681524-Oct-15 4:19 
GeneralPb deleting items Pin
forest200619-Jun-06 2:09
memberforest200619-Jun-06 2:09 
GeneralRe: Pb deleting items Pin
mistralthales19-Jun-06 5:36
membermistralthales19-Jun-06 5:36 
GeneralQuestion about adding messaging to grid Pin
zlatnik20-Feb-06 13:30
memberzlatnik20-Feb-06 13:30 
GeneralRe: Question about adding messaging to grid Pin
Marius Negrutiu21-Feb-06 0:05
memberMarius Negrutiu21-Feb-06 0:05 
GeneralRe: Question about adding messaging to grid Pin
zlatnik28-Feb-06 13:43
memberzlatnik28-Feb-06 13:43 
GeneralRe: Question about adding messaging to grid Pin
Marius Negrutiu1-Mar-06 3:58
memberMarius Negrutiu1-Mar-06 3:58 
Generalnice Pin
sstoyan16-Jan-05 6:44
membersstoyan16-Jan-05 6:44 
nice one. thank you
GeneralPb editing cell Pin
Forest20045-Dec-04 23:27
memberForest20045-Dec-04 23:27 
GeneralRe: Pb editing cell Pin
Marius Negrutiu6-Dec-04 0:02
memberMarius Negrutiu6-Dec-04 0:02 
GeneralRe: Pb editing cell Pin
Forest20046-Dec-04 0:09
memberForest20046-Dec-04 0:09 
GeneralRe: Pb editing cell Pin
Marius Negrutiu6-Dec-04 0:17
memberMarius Negrutiu6-Dec-04 0:17 
GeneralMDI Pin
Razi Al-Sayed21-Nov-04 9:41
memberRazi Al-Sayed21-Nov-04 9:41 
GeneralRealy nice... but need some help Pin
d00_ape21-Oct-04 3:01
memberd00_ape21-Oct-04 3:01 
QuestionHow can I Insert a dynamic Row in MFC CGridCtrl ?? Pin
biu-jee10-Sep-04 1:56
memberbiu-jee10-Sep-04 1:56 
GeneralSorting and full row select Pin
tomei26-Jul-04 0:22
membertomei26-Jul-04 0:22 
GeneralRe: Sorting and full row select Pin
Marius Negrutiu26-Jul-04 3:37
memberMarius Negrutiu26-Jul-04 3:37 
GeneralRe: Sorting and full row select Pin
tomei26-Jul-04 5:28
membertomei26-Jul-04 5:28 
Generalchanging the colour of the scroll-bars Pin
Alex Evans24-Jul-04 13:40
memberAlex Evans24-Jul-04 13:40 
GeneralNice, but heavily buggy ! Pin
Kochise10-Jun-04 23:54
memberKochise10-Jun-04 23:54 
GeneralRe: Nice, but heavily buggy ! Pin
Marius Negrutiu17-Jun-04 21:44
memberMarius Negrutiu17-Jun-04 21:44 
GeneralNot more crash, but still complicated... Pin
Kochise17-Jun-04 23:54
memberKochise17-Jun-04 23:54 
GeneralRe: Nice, but heavily buggy ! Pin
Thomas Freudenberg18-Jun-04 1:18
memberThomas Freudenberg18-Jun-04 1:18 

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.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web04-2016 | 2.8.180618.1 | Last Updated 18 Jun 2004
Article Copyright 2004 by Marius Negrutiu
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid