Click here to Skip to main content
Licence 
First Posted 9 Jun 2004
Views 84,733
Bookmarked 36 times

CGridCtrl 1.5

By | 17 Jun 2004 | Article
This article presents a tiny grid control derived from the standard list control

Introduction

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.

Features

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.

Multi-select

You can select multiple cells simultaneously (see screenshot).

Multi-edit

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.

Tips:

  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.

License

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

Member

- 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

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionWhere to set the cell style? Pinmemberhahakilokilo4:11 14 Jan '09  
GeneralCreating problems Pinmemberchs8-0711:08 19 Sep '07  
GeneralPb deleting items Pinmemberforest20062:09 19 Jun '06  
GeneralRe: Pb deleting items Pinmembermistralthales5:36 19 Jun '06  
GeneralQuestion about adding messaging to grid Pinmemberzlatnik13:30 20 Feb '06  
GeneralRe: Question about adding messaging to grid PinmemberMarius Negrutiu0:05 21 Feb '06  
GeneralRe: Question about adding messaging to grid Pinmemberzlatnik13:43 28 Feb '06  
GeneralRe: Question about adding messaging to grid PinmemberMarius Negrutiu3:58 1 Mar '06  
Generalnice Pinmembersstoyan6:44 16 Jan '05  
GeneralPb editing cell PinmemberForest200423:27 5 Dec '04  
GeneralRe: Pb editing cell PinmemberMarius Negrutiu0:02 6 Dec '04  
GeneralRe: Pb editing cell PinmemberForest20040:09 6 Dec '04  
GeneralRe: Pb editing cell PinmemberMarius Negrutiu0:17 6 Dec '04  
GeneralMDI PinmemberRazi Al-Sayed9:41 21 Nov '04  
GeneralRealy nice... but need some help Pinmemberd00_ape3:01 21 Oct '04  
QuestionHow can I Insert a dynamic Row in MFC CGridCtrl ?? Pinmemberbiu-jee1:56 10 Sep '04  
GeneralSorting and full row select Pinmembertomei0:22 26 Jul '04  
GeneralRe: Sorting and full row select PinmemberMarius Negrutiu3:37 26 Jul '04  
GeneralRe: Sorting and full row select Pinmembertomei5:28 26 Jul '04  
Generalchanging the colour of the scroll-bars PinmemberAlex Evans13:40 24 Jul '04  
GeneralNice, but heavily buggy ! PinmemberKochise23:54 10 Jun '04  
GeneralRe: Nice, but heavily buggy ! PinmemberMarius Negrutiu21:44 17 Jun '04  
GeneralNot more crash, but still complicated... PinmemberKochise23:54 17 Jun '04  
GeneralRe: Nice, but heavily buggy ! PinmemberThomas Freudenberg1:18 18 Jun '04  
GeneralIt's a grid, not a tree :/ PinmemberKochise2:54 18 Jun '04  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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 | Mobile
Web01 | 2.5.120517.1 | Last Updated 18 Jun 2004
Article Copyright 2004 by Marius Negrutiu
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid