Skip to main content
A newer version of this page is available. .

SpreadsheetControl.CloseCellEditor(CellEditorEnterValueMode) Method

Closes the cell editor.

Namespace: DevExpress.XtraSpreadsheet

Assembly: DevExpress.XtraSpreadsheet.v19.1.dll

Declaration

public bool CloseCellEditor(
    CellEditorEnterValueMode mode
)

Parameters

Name Type Description
mode CellEditorEnterValueMode

A CellEditorEnterValueMode enumeration member.

Returns

Type Description
Boolean

true, if the cell editor is closed successfully; otherwise, false.

Remarks

Use the CloseCellEditor method to close an open cell editor. To check whether a cell editor is currently active, use the SpreadsheetControl.IsCellEditorActive property. The CloseCellEditor method’s parameter specifies whether to commit an entered value to a cell or roll it back when the editor is closed.

Parameter

Description

Shortcut

Related Events

CellEditorEnterValueMode.ActiveCell

Commits an entered value to an active cell.

ENTER

SpreadsheetControl.CellEndEdit

SpreadsheetControl.CellValueChanged

CellEditorEnterValueMode.SelectedCells

Commits an entered value to all selected cells.

CTRL+ENTER

SpreadsheetControl.CellEndEdit

SpreadsheetControl.CellValueChanged

CellEditorEnterValueMode.ArrayFormula

Commits an entered formula to an active cell or selected cells as an array formula.

CTRL+SHIFT+ENTER

SpreadsheetControl.CellEndEdit

SpreadsheetControl.CellValueChanged

CellEditorEnterValueMode.Cancel

Cancels an entry in the cell editor.

ESC

SpreadsheetControl.CellCancelEdit

You can specify when the SpreadsheetControl.CellValueChanged event should occur after a cell value was edited and committed to a cell: each time, or only if a cell value was changed. To do this, use the SpreadsheetControl.Options.Behavior.CellEditor.CommitMode property (SpreadsheetCellEditorBehaviorOptions.CommitMode).

The following example shows how to use the CloseCellEditor method to commit changes in the active cell editor before the application is closed and save a document.

private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
    if (spreadsheetControl1.IsCellEditorActive)
        spreadsheetControl1.CloseCellEditor(CellEditorEnterValueMode.ActiveCell);
    if (spreadsheetControl1.Modified)
        spreadsheetControl1.SaveDocument();
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the CloseCellEditor(CellEditorEnterValueMode) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also