Cell Edit

A cell can enter edit mode if the user double-clicked on a cell (by default), or press F2 on the control. A text box will be placed on the control for receipting the user’s input.

An input form sample:
Styled Spreadsheet

Check Editing Cell

Method IsEditing can be used to check whether a cell is on edit mode.

bool result = sheet.IsEditing;

Method GetEditingCell can be used to get the position of current edit cell:

ReoGridCell cell = sheet.GetEditingCell();

Control in edit

Start edit

Method StartEdit is used to start an edit operation on a specified cell.

sheet.StartEdit(int row, int col);
sheet.StartEdit(CellPosition pos);

If there is any cell already on edit mode, the edit operation of the cell will be finished automatically.

Force to end edit

Method EndEdit can be used to force end an edit operation. The parameter ReoGridEndEditReason is used to decide what should be performed after ending the edit operation. For example, ReoGridEndEditReason.Cancel tells the control to abort the current edit content and restore the cell data to the last.

EndEdit(ReoGridEndEditReason reason);

The EndEdit method has another argument that can be used to set the data instead of the user’s input.

EndEdit(object data)
EndEdit(object data, ReoGridEndEditReason reason)

Prevent cell to start edit

Bind BeforeCellEdit event and set its IsCancelled property to false to prevent the cell edit from user’s double-click or F2.

sheet.BeforeCellEdit += (s, e) => e.IsCancelled = true;

Readonly cell

Property Readonly of cell instance can be used to disable the data edit, as well as paste operation.

var cell = sheet.Cells["A1"];
cell.Readonly = true;

Editing Events

It’s possible to handle the events of cell edit. For example, by handling the events of cell edit, it is possible to get the inputted characters during the edit, as well as replacing the input data with specified data. Learn more at here.


Next: Merge & Unmerge