Skip to main content

There are situations when you need to handle some events that are provided by a cell's editing cotrol in a DataGridView.

This can be done in the following way:

- Handle the DataGridView.EditingControlShowing event

- Access the DataGridViewEditingControlShowingEventArgs.Control property in order to get the editing control for the cell. If the event you are interested is not based on the Control class, maybe you need to perform casting the control to a specific control type.

Consider that the DataGridView control reuses editing controls across cells with the same type. This is why you need to be sure that your event handler is not called multiple times in the case when you hook up a new event handler if there is already one hooked up.

- Advertisement -
- Advertisement -