IDataGridViewEditingControl Interface
Collapse the table of content
Expand the table of content

IDataGridViewEditingControl Interface


Defines common functionality for controls that are hosted within cells of a DataGridView.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public interface class IDataGridViewEditingControl


Gets or sets the DataGridView that contains the cell.


Gets or sets the formatted value of the cell being modified by the editor.


Gets or sets the index of the hosting cell's parent row.


Gets or sets a value indicating whether the value of the editing control differs from the value of the hosting cell.


Gets the cursor used when the mouse pointer is over the DataGridView::EditingPanel but not over the editing control.


Gets or sets a value indicating whether the cell contents need to be repositioned whenever the value changes.


Changes the control's user interface (UI) to be consistent with the specified cell style.

System_CAPS_pubmethodEditingControlWantsInputKey(Keys, Boolean)

Determines whether the specified key is a regular input key that the editing control should process or a special key that the DataGridView should process.


Retrieves the formatted value of the cell.


Prepares the currently selected cell for editing.

This interface is implemented by controls, such as DataGridViewComboBoxEditingControl and DataGridViewTextBoxEditingControl, that are hosted by corresponding DataGridView cells, such as DataGridViewComboBoxCell and DataGridViewTextBoxCell, when they are in edit mode.

Cell types that can host editing controls set their EditType property to a Type representing the editing control type. When the cell enters edit mode, the following steps are performed:

  1. The DataGridView control creates an instance of the editing control type.

  2. The DataGridView control calls the cell InitializeEditingControl method. You can override this method to transfer the cell value to the editing control.

  3. The DataGridView control calls the editing control ApplyCellStyleToEditingControl method and passes in the cell's current style. You can implement this method to initialize the appearance of the editing control so that it matches the appearance of the cell.

  4. The DataGridView control calls the editing control PrepareEditingControlForEdit method. You can implement this method to make final adjustments to the editing control, such as selecting the control value.

For more information about implementing IDataGridViewEditingControl, see How to: Host Controls in Windows Forms DataGridView Cells.

Cell types such as DataGridViewCheckBoxCell that provide a user interface (UI) for specifying values without hosting an editing control implement the IDataGridViewEditingCell interface. The UI in this case is displayed regardless of whether the cell is in edit mode.

Other cell types, such as DataGridViewButtonCell, provide a UI but do not store user-specified values. In this case, the cell type does not implement IDataGridViewEditingCell or host an editing control.

The following code example provides an implementation of this interface that derives from DateTimePicker. This example is part of a larger example available in How to: Host Controls in Windows Forms DataGridView Cells.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top
© 2015 Microsoft