SpreadsheetControl.CloseCellEditor(CellEditorEnterValueMode) Method

Closes the cell editor.

Namespace: DevExpress.XtraSpreadsheet

Assembly: DevExpress.XtraSpreadsheet.v20.1.dll

Declaration

public bool CloseCellEditor(
    CellEditorEnterValueMode mode
)
Public Function CloseCellEditor(
    mode As CellEditorEnterValueMode
) As Boolean

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();
}
See Also