I'm hosting a custom editing control in a DataGridView, which for the record is a TextBox and Button together in a UserControl. I have inherited from DataGridViewColumn for the new column and DataGridViewTextBoxCell for the new cell.
With a normal DataGridViewTextBoxCell, if you press a key when the cell has focus, it will begin edit mode and the character you typed will appear in the TextBoxEditingControl. However, in my inherited cell, no value is being passed down on keypress. (In fact, you have to manually pass the current cell value in InitializeEditingControl or nothing will show up at all.) So, the first character you type (the one that begins edit mode) is lost.
I have tried OnKeyPress, OnKeyDown, and OnKeyUp in the DataGridViewCell but they never get called. KeyEntersEditMode, however, does seem to get called, and only when it is checking against a pressed key, so this might be a good place to start. The problem then becomes how to translate a KeyEventArgs to a char. This is trivial for alphabet and numbers, but since not all keyboards are created equal, handling other keys is messy and complicated at best. If there's a converter class that will do this automagically, please enlighten me.
Has anyone else encountered this problem or found a good workaround?
Note: This problem applies when EditMode is set to any variation of EditOnKeystroke. Setting to EditOnEnter is a valid workaround for my project, but I'd like to emulate the default behavior of the TextBoxEditingControl as well.