Occurs when a control for editing a cell is showing.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
You can handle this event to perform custom initialization of the editing control when a cell enters edit mode. To customize the display characteristics of the control, set the properties of the object returned by the DataGridViewEditingControlShowingEventArgs.CellStyle property. To perform other initialization, cast the value of the DataGridViewEditingControlShowingEventArgs.Control property to the specific control type and access the members directly. For example, you can handle the event to attach event-handlers to the events of the editing control.
The DataGridView control hosts one editing control at a time, and reuses the editing control whenever the cell type does not change between edits. When attaching event-handlers to the editing control, you must therefore take precautions to avoid attaching the same handler multiple times. To avoid this problem, remove the handler from the event before you attach the handler to the event. This will prevent duplication if the handler is already attached to the event, but will have no effect otherwise. For more information, see the example code in the DataGridViewComboBoxEditingControl class overview.
For more information about handling events, see Consuming Events.
The following code example illustrates how to handle this event to change the BackColor property of the current cell. To run this example, paste the code into a form that contains a DataGridView named dataGridView1 and ensure that the event is associated with the event handler.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.