BOOL SetExpressionRowCol(ROWCOL nRow, ROWCOL nCol, const CString& s, UINT flags = GX_UPDATENOW);
nRow
Specifies the row id.
nCol
Specifies the column id.
s
Specifies the text to be assigned to the cell.
flags
Specifies the update technique. See UpdateStyleRange.
TRUE if the text could be assigned to the cell; FALSE if an error occurred. You might check GetError to check the error state if this SetExpressionRowCol failed.
Parses the given text and based on the text content assigns a formula, a text label or a number to the specified cell. If you are using the formula engine and you want to force numeric or date values to be stored as string, insert an abostrophe ("'") at the beginning of the text. Formulas can be stored by inserting an equal sign ('=') at the beginning.
SetExpressionRowCol is an inline method that calls SetValueRange with nType set to GX_VALUE_EXPRESSION.
BOOL CGXGridCore::SetExpressionRowCol(ROWCOL nRow, ROWCOL nCol, const CString& s, UINT flags)
{
return SetValueRange(CGXRange(nRow, nCol), s, gxOverride, GX_VALUE_EXPRESSION, flags);
}
Example:
The following sample code shows how to fill a grid with formula expressions and text:
SetExpressionRowCol(nRow, 1, _T("STRCAT"));
SetExpressionRowCol(nRow+1, 1, _T("=STRCAT(F7, G7)"));
SetExpressionRowCol(nRow, 2, _T("LENGTH"));
SetExpressionRowCol(nRow+1, 2, _T("=LENGTH(F7)"));
SetExpressionRowCol(nRow, 3, _T("FIND"));
SetExpressionRowCol(nRow+1, 3, _T("=FIND(\"l\", F7, 0)"));
SetExpressionRowCol(nRow, 4, _T("MID"));
SetExpressionRowCol(nRow+1, 4, _T("=MID(F9&G9, 3, 5)"));
SetExpressionRowCol(nRow, 5, _T("LOWER"));
SetExpressionRowCol(nRow+1, 5, _T("=LOWER(F9&G9)"));
SetExpressionRowCol(nRow, 6, _T("REPEAT"));
SetExpressionRowCol(nRow+1, 6, _T("=REPEAT(\"=\", 10)"));
CGXFormulaSheet::SetExpressionRowCol CGXGridCore::SetValueRange
Class Overview | Class Members