CGXControl::m_bRefreshOnSetCurrentCell
BOOL m_bRefreshOnSetCurrentCell;
Remarks
Specifies whether your control needs to be refreshed when it becomes the current cell in the grid. If you set this attribute to be TRUE, some grid internal optimizations with outlining the current cell are turned off. These optimizations assume that the style of a cell does not change when it has become the current cell.
If your control’s appearance depends on whether it is a current cell or not, you should set this attribute TRUE (default is FALSE).
For example, if you have a password-control which should be drawn with plain text only when it is the current cell, you may set the m_bRefreshOnSetCurrentCell attribute of the specific control to be TRUE (see the attached example).
Example
This example demonstrates how to implement a control for entering passwords. When the user clicks in the cell, the password text will be shown. As soon as the user leaves the cell, only asterisks will be drawn in the cell.
CPasswordControl::CPasswordControl(CGXGridCore* pGrid, UINT nID)
: CGXEditControl(pGrid, nID)
{
// cell needs to be redrawn as soon as it becomes the current cell
m_bRefreshOnSetCurrentCell = TRUE;
}
BOOL CPasswordControl::GetControlText(CString& sResult, ROWCOL nRow, ROWCOL nCol, LPCTSTR pszRawValue, const CGXStyle& style)
{
// base class version will store current text in sResult
if (!CGXEditControl::GetControlText(sResult, nRow, nCol, pszRawValue, style))
return FALSE;
// check if it is the current cell (and maybe some other criteria)
if (Grid()->IsCurrentCell(nRow, nCol))
; // show text as it is
else
{
// replace text with asterisks '*'
for (int n = 0; n < sResult.GetLength(); n++)
sResult.SetAt(n, _T('*'));
}
return TRUE;
}
You might also override OnStartEditing() and determine if the user has the necessary privileges to edit the cell’s contents. If s/he does not have sufficient rights, you should return FALSE.
See Also
CGXGridCore::m_bRefreshOnSetCurrentCell