CGXGridParam::SetLockReadOnly
void SetLockReadOnly(BOOL b);
b
Specifies if protection of read-only cells in the grid shall be disabled or enabled. TRUE if cells shall be protected; FALSE otherwise.
Remarks
Call this method if you want to turn on/off the protection of read-only cells in the grid.
You can set the whole grid read-only with CGXGridCore::SetReadOnly and specific cells with CGXStyle::SetReadOnly. When you have read-only cells in the grid, these cells are protected against any changes from the end user and from the programmer. After setting cells (or the grid), you cannot apply any changes programmatically to the cell, and the user cannot change the cells. Although this makes sense, it is often necessary that the programmer be able to change the cell contents of read-only cells. SetLockReadOnly enables the programmer to change read-only cells.
You can change read-only cells if you call GetParam()->SetLockReadOnly(FALSE). This disables the read-only mode for all cells, and you can apply your changes. After changing the cells, you should call GetParam()->SetLockReadOnly(TRUE) (this is the default initial setting) which will reenable the protection for read-only cells.
Example:
SetStyleRange(CGXRange(1,1), CGXStyle().SetReadOnly(TRUE)); // Now, the user and the programmer cannot change the cell anymore. // Calling
SetLockReadOnlyturns off protection temporarily
GetParam()->SetLockReadOnly(FALSE).
// Now, I can change the cell:
SetStyleRange(CGXRange(1,1), CGXStyle().SetValue("Hello, World\n"));
// Reenable protection for cells
GetParam()->SetLockReadOnly(TRUE);
Some background:
Objective Grid always checks the read-only state of a cell with
if (GetParam()->IsLockReadOnly() && cell->GetReadOnly())
// can't apply changes, cell is read-only
See Also
CGXGridParam::IsLockReadOnly CGXGridCore::SetReadOnly CGXStyle::SetReadOnly