<< Return to Main Index

< Return to Class Index

CGXGridCore::SetControlTextRowCol

virtual BOOL SetControlTextRowCol(ROWCOL nRow, ROWCOL nCol, const CString& strDisplay, UINT flags = GX_UPDATENOW, const CGXStyle* pOldStyle = NULL);

nRow

Specifies the row id for the cell to be changed.

nCol

Specifies the column id for the cell to be changed.

strDisplay

A reference to a string which holds the text to be stored in the cell.

flags

Specifies the update technique. See UpdateStyleRange for more information.

pOldStyle

An optional pointer to an existing style object for the cell. SetControlText can use this object to determine information about the cell (e.g., input mask or read-only state) without having to gather the style information from the grid.

Return Value

TRUE if the text could be assigned to the cell; FALSE if the text was invalid.

Remarks

SetControlTextRowCol provides a hook for pasting text into the grid and lets you validate the text. You might add validation into this routine and also adjust the text before you store it in the grid (e.g., remove literals like the ‘$’ or ‘/’ from currency or date values).

SetControlTextRowCol will be called when you paste text from CF_TEXT clipboard format into the grid, or load data from a text file, or when text is cleared from cells with the ClearCells API. You should use this function as a hook for adjusting the data.

You can call SetControlTextRowCol directly if you want to assign text to a cell and let the cell convert the display text into the value which should be stored in the cell.

Value and cell text can be different. An example is tabbed combo boxes where an entry from a choice list is displayed in the cell and the key for that string is stored in the cell. Another example is masked edit. The text displayed in the cell contains literals (e.g., “(001)-999”). The value does not contain literals (e.g., “001999”)

SetControlTextRowCol calls CGXControl::SetControlText (unless you change its default behavior). CGXControl::SetControlText will convert the text into the raw value which should be stored in the cell and will then call SetValueRange to store that value in the grid.

See Also

CGXControl::GetControlText CGXGridCore::PasteTextFromBuffer

CGXGridCore

Class Overview | Class Members