officefileapi-devexpress-dot-spreadsheet-dot-customcellinplaceeditorcollection-dot-add-x28-devexpress-dot-spreadsheet-dot-cellrange-devexpress-dot-spreadsheet-dot-customcellinplaceeditortype-x29.md
Creates a custom cell in-place editor of the specified type and assigns it to the specified cell range.
Namespace : DevExpress.Spreadsheet
Assembly : DevExpress.Spreadsheet.v25.2.Core.dll
NuGet Package : DevExpress.Spreadsheet.Core
CustomCellInplaceEditor Add(
CellRange range,
CustomCellInplaceEditorType editorType
)
Function Add(
range As CellRange,
editorType As CustomCellInplaceEditorType
) As CustomCellInplaceEditor
| 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.
|
| Type | Description |
|---|---|
| CustomCellInplaceEditor |
A CustomCellInplaceEditor object that specifies the created custom cell in-place editor.
|
Use the Add method to assign an in-place editor of the predefined type to a specific cell range in a worksheet. If the predefined editors do not comply with your requirements, handle the SpreadsheetControl.CustomCellEdit event to assign your own custom editor to worksheet cells. For details, refer to the How to: Assign Custom In-place Editors to Worksheet Cells 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");
' Use a date editor as the in-place editor for cells located in the "Order Date" column of the worksheet table.
Dim dateEditRange As CellRange = 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.
Dim comboBoxRange As CellRange = 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.
Dim checkBoxRange As CellRange = 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.
Dim customRange As CellRange = worksheet("Table[Qty]")
worksheet.CustomCellInplaceEditors.Add(customRange, CustomCellInplaceEditorType.Custom, "MySpinEdit")
The following code snippets (auto-collected from DevExpress Examples) contain references to the Add(CellRange, CustomCellInplaceEditorType) 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.
CellRange dateEditRange = worksheet["Table[Order Date]"];
worksheet.CustomCellInplaceEditors.Add(dateEditRange, CustomCellInplaceEditorType.DateEdit);
winforms-spreadsheet-assign-custom-in-place-editors/CS/Spreadsheet_CustomCellEditors/Form1.cs#L34
CellRange dateEditRange = worksheet["Table[Order Date]"];
worksheet.CustomCellInplaceEditors.Add(dateEditRange, CustomCellInplaceEditorType.DateEdit);
Dim dateEditRange As CellRange = 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.
winforms-spreadsheet-assign-custom-in-place-editors/VB/Spreadsheet_CustomCellEditors/Form1.vb#L30
Dim dateEditRange As CellRange = 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.
winforms-spreadsheet-use-custom-cell-editors/VB/DevAVInvoicing/Form1.vb#L49
' Use a date editor as the in-place editor for cells containing the shipping date in the "Ship date" column.
invoice.CustomCellInplaceEditors.Add(invoice("F18:G18"), CustomCellInplaceEditorType.DateEdit)
' Use a combo box editor as the in-place editor for cells allowing a user to select the preferred shipping method in the "Ship via" column.
See Also
CustomCellInplaceEditorCollection Interface