ReoGrid
DOCUMENT
Cell Edit

Cells enter edit mode when the user double-clicks or presses F2. ReoGrid overlays a text box on top of the cell to capture input.

An input form sample: Styled Spreadsheet

Check edit state

Use IsEditing to know whether any cell is currently in edit mode:

bool result = sheet.IsEditing;

Use GetEditingCell to retrieve the cell being edited:

ReoGridCell cell = sheet.GetEditingCell();

Control editing programmatically

Start editing

Invoke StartEdit on a worksheet to begin editing a cell. If another cell is already in edit mode, ReoGrid ends that session first.

sheet.StartEdit(2, 3);                // row 3, column 4
sheet.StartEdit(new CellPosition("A1"));

End editing

Use EndEdit to finish an edit. Passing a ReoGridEndEditReason controls what happens after the edit. Cancel discards changes; other reasons commit them.

sheet.EndEdit(ReoGridEndEditReason.Cancel);

You can also end editing and assign a value at the same time:

sheet.EndEdit("New Value");
sheet.EndEdit("New Value", ReoGridEndEditReason.Normal);

Readonly cells

Set a cell’s Readonly property to block editing and paste:

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

Control input behavior

Disable automatic data formatting while typing:

worksheet.SetSettings(WorksheetSettings.Edit_AutoFormatCell, false);

Disable the friendly percent helper (ReoGrid appends % by default when editing percent cells):

worksheet.SetSettings(WorksheetSettings.Edit_FriendlyPercentInput, false);

More worksheet settings are covered in Settings.

Handle edit events

ReoGrid raises events before, during, and after edit mode. You can cancel an edit, validate text, or transform user input.

150

Before editing

BeforeCellEdit fires right before the edit box appears. Set IsCancelled = true to block editing (e.g., for double-click or F2):

sheet.BeforeCellEdit += (sender, e) =>
{
  e.IsCancelled = true;
};

During editing

Use these events for lightweight validation and transforms:

  • CellEditTextChanging: fires when the edit text changes (typing, paste, IME). Set Text to replace the full string.
  • CellEditCharInputed: fires per character; WPF cannot alter characters here—use CellEditTextChanging instead.

Example validation/transform:

void OnCellEditTextChanging(object sender, CellEditTextChangingEventArgs e)
{
  if (e.Text.Equals("specific input"))
  {
    e.Text = "predefined data";
  }
}

sheet.CellEditTextChanging += OnCellEditTextChanging;

After editing

Editing ends when the user presses Enter or moves focus. AfterCellEdit always fires; set IsCancelled = true inside it to revert to the original value. CellDataChanged fires only when data actually changes (not when Escape cancels the edit).

CellDataChanged also fires for programmatic edits (e.g., SetCellData or paste), making it the final hook for observing or adjusting data changes.

Data Validation

ReoGrid supports data validation to control what users can enter into cells. You can define validation rules, display input prompts, and show error messages when invalid data is entered. This helps maintain data integrity and provides a better user experience.

For detailed information on setting up validation rules and handling validation events, see Data Validation.


Was the content of the page helpful?

© 2012-2025UNVELL Inc.