Objective Grid: Changing the appearance of a cell

Article ID: 487
Last updated: 25 Apr, 2018
Article ID: 487
Last updated: 25 Apr, 2018
Revision: 3
Views: 1730
Posted: 12 Jan, 2001
by Meltreger B.
Updated: 25 Apr, 2018
by Meltreger B.

Problem

 


Is there a virtual method that I can override to change the appearance of the current cell?

 

 


Cause

 


 

 


Action

 


You should override GetStyleRowCol( ) and set the interior-attribute for the cell depending on the current cell position.

Furthermore you should set m_bRefreshOnSetCurrentCell = TRUE so that the current cell gets redrawn when you use the arrow keys to navigate in the grid.

Example:

BOOL CBrowserView::GetStyleRowCol(ROWCOL nRow, ROWCOL nCol, CGXStyle& style, GXModifyType mt, int nType)
{
if (!base_class::GetStyleRowCol(nRow, nCol, style, mt, nType))
return FALSE;
// You may also initialize the following
// attribute in your OnInitialUpdate method.
m_bRefreshOnSetCurrentCell = TRUE;

// Check if this is the current cell
if (!IsPrinting() && nRow > 0 && nCol > 0)
{

// NOTE: This is only an example.
// You may customize the behavior
// to your specific needs. Using
// the grids default outlining of
// the current cell will probably
// look better than this sample
// (has a nicer border).
if (IsCurrentCell(nRow, nCol))
{
// Draw background of cell red
style.SetInterior(RGB(255,0,0));

// Draw border in highlight around
// current cell
style.SetBorders(gxBorderAll,

CGXPen().SetWidth(1).SetColor(COLOR_HIGHLIGHT));
// NOTE: If you want to do this,
// you should disable the default
// outlining of the current cell
// by placing the following lines
// in your OnInitialUpdate routine:
//
// CGXProperties* pProp = GetParam()->GetProperties();
// pProp->SetUserProperty(GX_IDS_OUTLINECURRENTCELL,
// (CGXStyle) pProp->sInvertNoBorder);
}
}

return TRUE;

}

This article was:   Helpful | Not helpful
Report an issue
Article ID: 487
Last updated: 25 Apr, 2018
Revision: 3
Views: 1730
Posted: 12 Jan, 2001 by Meltreger B.
Updated: 25 Apr, 2018 by Meltreger B.

Others in this category