Using a RichEdit Control in the MFC Grid Control

Environment: VC6, Win9x, NT4, W2K, MFC

Introduction

I was looking for a code to add extra features to the MFC Grid Control so that the user can format the cells as in a spreadsheet program. So, I've created a demo project that shows how to replace the default editing with a Rich Edit Control.

Using the Code

Two new classes are added to implement this new cell type into a MFC Grid control:

  • CInPlaceRichEdit, derived from CRichEditCtrl. This class allows the user to edit the content of a cell and change the text attributes (bold, italic, underline).
  • CGridCellRich, derived from CGridCell. This class draws the formatted text in the cell, and adds the extra formatting features.

Using the new cell is simple. For example, you can call CGridCtrl::SetDefaultCellType like this:

m_Grid.SetCellType (row,col, RUNTIME_CLASS(CGridCellRich));

For more information on how to use a owner cell type, read the Chris Maunder article here.

Thanks

Thanks to Chris Maunder for his great MFC Grid Control.

Version History

01/03/2004: first release.

Downloads

Download demo project - 47 Kb
Download source - 102 Kb


Comments

  • virtualmode

    Posted by Legacy on 02/18/2004 12:00am

    Originally posted by: Pietro

    excuse my english,i'm italian.
    I'm writing an activex with some features on the grid.
    I use the virtual mode.It's possible editing of cells in virtual mode?

    Reply
  • Question...

    Posted by Legacy on 01/20/2004 12:00am

    Originally posted by: Puiu

    Please excuse my english! (i'm not a native english speaker)
    How can I insert a CDateTimeCtrl in a cell of grid? I know that isn't linked by this subject but I realy need to do this how soon is possible!
    Please help me!Tnx!

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Learn How A Global Entertainment Company Saw a 448% ROI Every business today uses software to manage systems, deliver products, and empower employees to do their jobs. But software inevitably breaks, and when it does, businesses lose money -- in the form of dissatisfied customers, missed SLAs or lost productivity. PagerDuty, an operations performance platform, solves this problem by helping operations engineers and developers more effectively manage and resolve incidents across a company's global operations. …

  • Live Event Date: December 18, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT The Internet of Things (IoT) incorporates physical devices into business processes using predictive analytics. While it relies heavily on existing Internet technologies, it differs by including physical devices, specialized protocols, physical analytics, and a unique partner network. To capture the real business value of IoT, the industry must move beyond customized projects to general patterns and platforms. Check out this upcoming webcast …

Most Popular Programming Stories

More for Developers

RSS Feeds