The CellEditorManager class allows any control to be used as an editor to edit the content of a cells.
Custom CellEditorManagers can be created by deriving from the CellEditorManager class and implementing the required functionalities, by handling the events that are raised by the CellEditorManager class, or by wrapping a control within an instance of the CellEditorManager class. By default, Xceed Grid for WinForms offers the following predefined CellEditorManager controls: the CheckBoxEditor control which can be used to edit the content of cells which have a boolean datatype, the TextEditor control which can be used to edit the content of cells which have a string datatype, the ComboBoxEditor control which can be used to edit the content of cells which have an ID/Value mapping, the DateEditor control which can be used to edit the content of cells which have a DateTime datatype, and the NumericEditor control which can be used to edit the content of cells which have a numeric datatype.
The following table provides a list of the available CellEditorManagers as well as the datatype for which they are created by default.
CellEditorManagers | Datatype | Description |
---|---|---|
CellEditorManager | (none) | Allows for any control to be used as an editor to edit the content of a cell. |
CheckBoxEditor | Boolean | Represents an editor that can be used to edit the content of cells which have a boolean datatype. |
ComboBoxEditor | (none) | Represents an editor that can be used to edit the content of cells which have an ID/value mapping. |
DateEditor | DateTime | Represents an editor that can be used to edit the content of cells which have a DateTime datatype. |
NumericEditor | Numeric | Represents an editor that can be used to edit the content of cells which have a numeric datatype. |
TextEditor | String | Represents an editor that can be used to edit the content of cells which have a string datatype. |
The default CellEditorManagers that are created can be removed or replaced with one of the above mentioned predefined CellEditorManagers or with a custom CellEditorManager by setting the CellEditorManager property of either or a column or a specific cell.
VB.NET | Copy Code |
---|---|
GridControl1.Columns( "Phone" ).CellEditorManager = New TextEditor( "( ### ) ###-####" ) |
C# | Copy Code |
---|---|
gridControl1.Columns[ "Phone" ].CellEditorManager = new TextEditor( "( ### ) ###-####" ); |
Custom CellEditorManagers can be created by deriving from the CellEditorManager class and implementing the required functionalities, by handling the events that are raised by the CellEditorManager class, or by wrapping a control within an instance of the CellEditorManager class.
The GridControl class exposes the CellEditorManagerMapping property which contain a list of the CellEditorManagers which are created by default for specified datatypes. Values contained in this collection can be modified, added, or removed to change the CellEditorManager which is created by default for all columns of the specified datatype.
The CellEditorDisplayConditions property indicates under what conditions the CellEditorManager's TemplateControl (or cloned instance of the TemplateControl) is displayed. Combinations of the CellEditorDisplayConditions can be used and specified at the Cell, CellRow, Column, GridControl, and DetailGrid levels.
The following table provides a list of the possible values for the CellEditorDisplayConditions property:
Value | Description |
---|---|
None | A cell's editor is only displayed when the cell is being edited. |
MouseOverCell | A cell's editor is displayed when the mouse passes over a cell. MouseOverCell will only function in the case where CreateControlMode is set to ClonedInstance. |
MouseOverRow | The cell editors of each cell in a row are displayed when the mouse passes over a row. MouseOverRow will only function in the case where CreateControlMode is set to ClonedInstance. |
RowIsBeingEdited | The cell editors of each cell in a row are displayed when one of the cells in the row is being edited. |
RowIsCurrent | The cell editors of each cell in the current row are displayed. |
CellIsCurrent | The editor for the current cell is displayed. |
Always | The cell editors for each cell in the grid are always displayed. Always will only function in the case where CreateControlMode is set to ClonedInstance. Setting the CellEditorDisplayConditions property to Always will have a significant negative impact on performance. |
Controls can be wrapped in a CellEditorManager by either deriving from the CellEditorManager class, or by using the constructor that accepts a control as a parameter. This section only deals with wrapping a control through the appropriate constructor. For information on how to derive from the CellEditorManager, refer to the CellViewerManager and CellEditorManager extensions topic
When wrapping a control in a CellEditorManager, the control used as a template control to edit a cell's content, the property used to retrieve the control's value, as well as other pertinent information must be specified. All the values passed at construction can be accessed (not modified) through the TemplateControl and InPlace properties.
The appearance of the underlying control can be modified before it is passed to the CellEditorManager, or during the SettingControlAppearance event. If the appearance of the underlying control is the same regardless of the cell's content, then its appearance should be defined directly on the instance of the control. For example:
VB.NET | Copy Code |
---|---|
Dim bar As New TrackBar() |
C# | Copy Code |
---|---|
TrackBar bar = new TrackBar(); |
By default, the value will be retrieved from the underlying control via the property name that was specified when the CellEditorManager was constructed; however, there are some cases where modifications need to be made to the value that is retrieved before it can be assigned to the cell. These modifications can be done via the GettingControlValue event. For example, to continue the above example, we will convert the value retrieved from the underlying control to the value's datatype before it is assigned to the cell using the GettingEditorControlValueEventArgs. CellValue property:
VB.NET | Copy Code |
---|---|
AddHandler manager.GettingControlValue, AddressOf Me.manager_GettingControlValue |
C# | Copy Code |
---|---|
manager.GettingControlValue += new GettingEditorControlValueEventHandler( manager_GettingControlValue ); |
A complete list of the public properties, methods, and events that are available on the CellEditorManager class is available here.