Is there any way to get underlying control for a DataGridView cell?
I would like to attach normal texbox events to capture keystrokes and capture value changed.
So i have 4 columns, each of them contains number of cells and all cells in one row should be handled different way based on its type.
Basically i need my events to be fired only when a cell is being edited.
Subscribe the
DataGridView.EditingControlShowingevent, then subscribe theTextBoxevent you need.Example with
TextBox.KeyDown:EDIT:
Now the code is more correct, because it follows the suggestion given on MSDN:
EDIT 2:
As per comment:
TextChangedevent is called beforeEditingControlShowing, and then again after it.You can distinguish between the two calls using this trick: