CustomCellInplaceEditorCollection.Add(CellRange, CustomCellInplaceEditorType, ValueObject) Method
Creates a custom cell in-place editor with the specified settings and assigns it to the specified cell range.
Namespace: DevExpress.Spreadsheet
Assembly: DevExpress.Spreadsheet.v24.2.Core.dll
NuGet Package: DevExpress.Spreadsheet.Core
Declaration
CustomCellInplaceEditor Add(
CellRange range,
CustomCellInplaceEditorType editorType,
ValueObject value
)
Parameters
Name | Type | Description |
---|---|---|
range | CellRange | A CellRange object that specifies a cell or cell range to which the custom in-place editor should be assigned. |
editorType | CustomCellInplaceEditorType | A CustomCellInplaceEditorType enumeration member that specifies the type of the custom editor to be used for in-place editing. |
value | ValueObject | A ValueObject object that specifies a value associated with the custom cell in-place editor. For a combo box editor (CustomCellInplaceEditorType.ComboBox), this value specifies a list of items to be displayed in the editor’s drop-down list. |
Returns
Type | Description |
---|---|
CustomCellInplaceEditor | A CustomCellInplaceEditor object that specifies the created custom cell in-place editor. |
Remarks
Use the Add method to assign an in-place editor of the predefined type to worksheet cells. If you use a combo box editor for cell editing (the editorType parameter is CustomCellInplaceEditorType.ComboBox), the method’s value parameter allows you to supply items for the editor’s drop-down list. You can directly pass a string of comma-separated items or use the ValueObject.FromRange method to obtain the required items from a cell range in a worksheet. Using types of values other than a text string or cell range is not allowed (otherwise, a System.ArgumentException will be raised).
If you select the CustomCellInplaceEditorType.Custom editor type, you must handle the SpreadsheetControl.CustomCellEdit event to define a specific editor to be assigned to the specified cell range.
For an example on how to use custom editors for in-place editing of cell content, refer to the How to: Assign Custom In-place Editors to Worksheet Cells article.
Example
// Use a date editor as the in-place editor for cells located in the "Order Date" column of the worksheet table.
CellRange dateEditRange = worksheet["Table[Order Date]"];
worksheet.CustomCellInplaceEditors.Add(dateEditRange, CustomCellInplaceEditorType.DateEdit);
// Use a combo box editor as the in-place editor for cells located in the "Category" column of the worksheet table.
// The editor's items are obtained from a cell range in the current worksheet.
CellRange comboBoxRange = worksheet["Table[Category]"];
worksheet.CustomCellInplaceEditors.Add(comboBoxRange, CustomCellInplaceEditorType.ComboBox, ValueObject.FromRange(worksheet["J3:J9"]));
// Use a check editor as the in-place editor for cells located in the "Discount" column of the worksheet table.
CellRange checkBoxRange = worksheet["Table[Discount]"];
worksheet.CustomCellInplaceEditors.Add(checkBoxRange, CustomCellInplaceEditorType.CheckBox);
// Use the custom control (SpinEdit) as the in-place editor for cells located in the "Quantity" column of the worksheet table.
// To provide the required editor, handle the CustomCellEdit event.
CellRange customRange = worksheet["Table[Qty]"];
worksheet.CustomCellInplaceEditors.Add(customRange, CustomCellInplaceEditorType.Custom, "MySpinEdit");
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the Add(CellRange, CustomCellInplaceEditorType, ValueObject) 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.