CGXStyle::SetReadOnly

CGXStyle& SetReadOnly(BOOL b);

b

Specifies the new setting.

Return Value

Returns the this pointer.

Remarks

Initializes the read only setting.

After a cell has been set read-only no changes can be made to the cell. Any subsequent calls to SetStyleRange or SetValueRange will be ignored and return FALSE to indicate that the operation failed.

Please note that although an edit cell cannot be changed when you set it read-only, the user can still activate the cell and make the flashing caret become visible. If you want the cell to stay static even if the user clicks into the edit cell, you should change the cell type to static by calling SetControl(GX_IDS_CTRL_STATIC).

The CGXGridParam::SetLockReadOnly method lets you turn off the protection of read-only cells and allows you to make changes.

Here are two frequently asked questions:

Q1: How to programmatically change cells that have been marked read-only?

A: Call SetLockReadOnly(FALSE) before changing read-only cells, change the cells and then call SetLockReadOnly(TRUE) again.

Q2: How to make read-only cells writeable again?

A: Call

GetParam()->SetLockReadOnly(FALSE);

SetStyleRange(range, CGXStyle().SetReadOnly(FALSE));

GetParam()->SetLockReadOnly(TRUE);

See Also

 CGXGridParam::SetLockReadOnly  CGXStyle::SetControl

CGXStyle

 Class Overview |  Class Members