Objective Grid: Storing text as a string in cells with formula support

Article ID: 323
Last updated: 11 Jun, 2018
Article ID: 323
Last updated: 11 Jun, 2018
Revision: 3
Views: 1963
Posted: 24 Jan, 2001
by Meltreger B.
Updated: 11 Jun, 2018
by Meltreger B.

Problem


How do I force text to be stored as a string (GX_VT_STRING value type) for individual cells when formula support is enabled?


Cause


The formula engine parses the string that gets entered into a edit cell and when it is a valid number, the engine will store the value as plain number. Leading zeros and trailing digits will be ignored.


Action


The user can force the input to be stored as string by inserting an apostrophe before the number. However, this is sometimes not a sufficient solution.

If you want to programmatically force individual cells always to be stored as string, override the StoreStyleRowCol() method as follows:

BOOL CMyFormulaGrid::StoreStyleRowCol(ROWCOL nRow, ROWCOL nCol, const CGXStyle* pStyle, GXModifyType mt, int nType)
{
if (nRow and nCol meets your criteria)
nType = 0;
return CGXGridCore::StoreStyleRowCol(nRow, nCol, pStyle, mt, 0);
}

If nType is equal to zero the formula engine will not parse the value and store the value as string.

See the class reference for SetExpressionRowCol(), SetTextRowCol() and SetFormatRowCol() for more information.

This article was:   Helpful | Not helpful
Report an issue
Article ID: 323
Last updated: 11 Jun, 2018
Revision: 3
Views: 1963
Posted: 24 Jan, 2001 by Meltreger B.
Updated: 11 Jun, 2018 by Meltreger B.

Others in this category