Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » How to change the cell type of outerright column? Collapse All
Subject Author Date
Francesco Toscano Sep 4, 2007 - 11:32 AM

I do not know if it is possible, I think that should be. I would like to change the cell type for the outer right column, in my case, I would like to use a Check Box type cell instead of the default one. But at the moment I have not found any solution. I am working on a cacheble database grid. If what I am asking it is possible, Could you please give me an example on how I can do it? If yes, because I am using a cacheble database grid (derived from CExtGridWnd), where is the right place to do this cell type change?

Many thanks
Francesco Toscano.

Francesco Toscano Sep 5, 2007 - 9:15 AM

First of all thanks for your fast reply then thanks for the detailed explanation. Now it is the much clearer way in which these classes works.

But now I have another question:
Since I would want to change, in the way you suggested, the Cells that are OuterAtRight of af cacheble DatabaseGrid grid.

Because a cacheable grid constantly updates cached cell range during scrolling, where is the best place to instantiate this check box class? Actually I fill the data cells and header in the my derived "CExtGridDataProvider" (as you do in your sample). Because I do not need to fill these cells with data or other ( I just want a selectable check box for every row in grid), It can be done just one time during initialization?

Your suggestions are welcome!

Francesco Toscano

Technical Support Sep 5, 2007 - 12:34 PM

We suppose you created a CExtGridDataProviderRecordset-derived class that implements your cacheable grid and overrode the CExtGridDataProviderRecordset::RsCacheRow() virtual method in it. Both the data and outer header cells should be initialized in this method for each row. Let us suppose you have 2 header columns on the left (L0 and L1), 5 data rows (D0, D1, D2, D3 and D4) and 3 header columns on the right (R0, R1 and R2). In this case, each visible row in your grid should look like as follows:

L0  L1        D0  D1  D2  D3  D4        R0  R1  R2
The data provider keeps an array of grid cells for each row in the following order:
L0  L1  R0  R1  R2 D0  D1  D2  D3  D4
So, your version of the RsCacheRow() virtual method should initialize row cells in the same order.


Technical Support Sep 5, 2007 - 5:51 AM

Most of the features of all grid cells are implemented in the basic CExtGridCell class, including built-in support for a check box, an image, text, a drop-down button, an up-down button and an ellipsis button. The CExtGridCellCheckBox class just provides a simpler API for working with a check box cell. The CExtGridCellComboBox class provides an API similar to that in the combo box control and it manages a collection of strings. Some other classes provide alternative data for editing and alternative in-place editor windows instead of a simple single line edit control provided by the CExtGridCell class. You can use any cell class in outer header areas. The only difference between outer header cells and data cells is that they optionally should store column minimal/maximal/current widths (current width values in pixels and/or double values for proportional column resizing) and row minimal/maximal/current heights (current height values in pixels and/or double values for proportional row resizing) when your grid window uses variable/resizable columns and/or rows. The CExtGridCellHeader class implements a grid cell which is a simple string cell class with the ability to store row height or column width values called extents. To make any grid cell able to store extents in pixels, you should apply the CExtGCE template decorator class to it. To make any grid cell able to store proportional extents, you should apply the CExtGCP template decorator class to it. There are several other template decorator classes for extending capabilities of grid cells, but they are not related to your question. For example, the CExtGridCellHeader class is declared as follows:

class CExtGridCellHeader
      : public CExtGCF < CExtGCC < CExtGCP < CExtGCE < CExtGridCellStringDM > > > >
{
. . .
As you can see, both the CExtGCE and CExtGCP template classes are present in it. You can create the same class based on the check box cell and use it in header areas:
class CYourCheckBoxCellForOuterHeaderArea : public CExtGCP < CExtGCE < CExtGridCellCheckBox > >
{
public:
      DECLARE_SERIAL( CYourCheckBoxCellForOuterHeaderArea );
      IMPLEMENT_ExtGridCell_Clone( CYourCheckBoxCellForOuterHeaderArea, CExtGCP < CExtGCE < CExtGridCellCheckBox > > );
      CYourCheckBoxCellForOuterHeaderArea( CExtGridDataProvider * pDataProvider = NULL )
            : public CExtGridCellCheckBox( pDataProvider )
      {
      }
      CYourCheckBoxCellForOuterHeaderArea( const CExtGridCell & other )
            : public CExtGridCellCheckBox( other )
      {
      }
      virtual ~CYourCheckBoxCellForOuterHeaderArea()
      {
      }
};

// The following line of code should be placed at the beginning of .CPP file before definition
// of the MFC debug version of the new operator:

IMPLEMENT_SERIAL( CYourCheckBoxCellForOuterHeaderArea, CExtGridCellCheckBox, VERSIONABLE_SCHEMA|1 );
To instantiate this check box class in the header areas of the CExtGridWnd control you should simply use it in the invocation of the CExtGridWnd::GridCellGet***() methods:
CExtGridWnd * pGrid = . . .
      CExtGridCell * pCell = pGrid->GridCellGetOuterAtTop( nColNo, nRowNo, RUNTIME_CLASS( CYourCheckBoxCellForOuterHeaderArea ) );
      if( pCell != NULL )
      {
            CYourCheckBoxCellForOuterHeaderArea * pYourCell =
                  STATIC_DOWNCAST( CYourCheckBoxCellForOuterHeaderArea, pCell );
            . . .
      }