Highlight the background of the current cell

Article ID: 744
Last updated: 06 Jun, 2018
Article ID: 744
Last updated: 06 Jun, 2018
Revision: 3
Views: 2095
Posted: 22 Aug, 2005
by Meltreger B.
Updated: 06 Jun, 2018
by Meltreger B.

Problem


How to highlight the background of the current cell in Objective Grid?


Cause



Action


The following steps show how to highlight the background of current cell in objective Grid.

1) Override the virtual function SetCurrentCell.

For example, in the 1stGrd32 sample shipped with Objective Grid, you add the following code in the header file for C1stGridView class:

BOOL SetCurrentCell(ROWCOL nRow, ROWCOL nCol, UINT flags = GX_SCROLLINVIEW | GX_UPDATENOW);

2) Call the function SetInterior to set the desired background color for the current cell, and also to set the last selected cell to default background color.

For example, in the 1stGrd32 sample, the following code highlights a red background for the currently selected cell:

BOOL C1stGridView::SetCurrentCell(ROWCOL nRow, ROWCOL nCol, UINT flags)
{
 ROWCOL nRowOld, nColOld;
 GetCurrentCell(nRowOld, nColOld);
 if (nRowOld && nColOld)
 SetStyleRange(CGXRange(nRowOld, nColOld),
    CGXStyle().SetInterior(RGB(255,255,255)));
 if (nRow && nCol)
    SetStyleRange(CGXRange(nRow, nCol),
    CGXStyle().SetInterior(RGB(255,0,0)));
return CGXGridView::SetCurrentCell(nRow, nCol, flags);
}

An alternative approach to highlight the currently selected cell can be found in the following knowledge base article:

http://www.roguewave.com/support/private/ts/viewsrchdoc.cfm?issn=000710-045

This article was:   Helpful | Not helpful
Report an issue
Article ID: 744
Last updated: 06 Jun, 2018
Revision: 3
Views: 2095
Posted: 22 Aug, 2005 by Meltreger B.
Updated: 06 Jun, 2018 by Meltreger B.

Others in this category