Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.
I have a DataGridView where I allow users to type in cell values, but I only want upper case. To do this, you need to capture the control as it's being created and assign a KeyPress handler. E.g:
private void MyGrid_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { if (e.Control is DataGridViewTextBoxEditingControl) { e.Control.KeyPress += new KeyPressEventHandler(Control_KeyPress); } }
void Control_KeyPress(object sender, KeyPressEventArgs e) { e.KeyChar = e.KeyChar.ToString().ToUpper()[0]; }
Of course, you can extend this further to do all sort of things, but if your requirements are complex then it's probably advisable to create your own custom column.