Skip to main content

SpreadsheetControl.CustomCellEdit Event

Allows you to assign a custom in-place editor to a cell.

Namespace: DevExpress.XtraSpreadsheet

Assembly: DevExpress.XtraSpreadsheet.v23.2.dll

NuGet Package: DevExpress.Win.Spreadsheet

Declaration

public event SpreadsheetCustomCellEditEventHandler CustomCellEdit

Event Data

The CustomCellEdit event's data class is SpreadsheetCustomCellEditEventArgs. The following properties provide information specific to this event:

Property Description
Cell Gets the cell for which the event is fired. Inherited from SpreadsheetCellEventArgsBase.
ColumnIndex Gets the index of the column that contains the cell. Inherited from SpreadsheetCellEventArgsBase.
Formula Gets the formula that is currently contained in the cell. Inherited from SpreadsheetCellEventArgsBase.
FormulaInvariant Gets the formula in the invariant culture that is currently contained in the cell. Inherited from SpreadsheetCellEventArgsBase.
RepositoryItem Gets or sets the in-place editor for the current cell.
RowIndex Gets the index of the row that contains the cell. Inherited from SpreadsheetCellEventArgsBase.
SheetName Gets the name of the worksheet that contains the cell. Inherited from SpreadsheetCellEventArgsBase.
Value Gets the value currently contained in the cell. Inherited from SpreadsheetCellEventArgsBase.
ValueObject Gets a value associated with the CustomCellInplaceEditor object assigned to the cell.
Worksheet Gets the worksheet that contains the cell. Inherited from SpreadsheetCellEventArgsBase.

Remarks

The CustomCellEdit event fires each time an end user starts to edit a cell and allows you to replace the built-in cell editor with a custom one. The event’s Cell, ColumnIndex and RowIndex parameters help you identify the currently edited cell. To supply a custom editor to the cell, create a RepositoryItem descendant corresponding to the editor you want to use and assign it to the event’sDevExpress.XtraSpreadsheet.SpreadsheetCustomCellEditEventArgs.RepositoryItem parameter. Refer to the Editors and Simple Controls topic for additional information on this mechanism. The Included Controls and Components document lists available editors and their corresponding repository items.

The code snippet below shows how to assign a spin editor to the sixth column’s cells.

Spreadsheet_Example_CustomCellEditors_SpinEdit

spreadsheetControl.CustomCellEdit += spreadsheetControl_CustomCellEdit;
// ...

//Create a repository item corresponding to a SpinEdit control
RepositoryItemSpinEdit repository = new RepositoryItemSpinEdit();
private void spreadsheetControl_CustomCellEdit(object sender, DevExpress.XtraSpreadsheet.SpreadsheetCustomCellEditEventArgs e)
{
    if (e.SheetName == "Sales report" && e.ColumnIndex == 5 && e.RowIndex > 1)
    {
        //specify the repository item settings.
        repository.AutoHeight = false;
        repository.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;

        repository.MinValue = 1;
        repository.MaxValue = 1000;
        repository.IsFloatValue = false;
        // Assign the spin editor to a cell.
        e.RepositoryItem = repository;
    }
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CustomCellEdit event.

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