How to detect each keystroke in datagridview cell
Hi,
I need to detect each keystroke in datagridview cell.
I found a class called DataGridViewTextBoxCell with its protected OnKeyDown method.
I thought the pseudo - code might be something like this:
DataGridViewTextBoxCell c = this.datagrid1[column, row]
c.KeyDown += KeyDown();
then
protected override void KeyDown(object sender, KeyEventArgs e)
{
//detect it over here
}
I might be wrong though.
Help anyone?
[453 byte] By [
Devi] at [2007-12-25]
The DataGridViewTextBoxCell class is a specific type of DataGridViewCell. If you are sure that the cell you are referencing is a DateGridViewTextBoxCell, your code will probably work.
However, I think you use the DataGridViewCell class to detect the keystroke. Just remember that KeyDow only detects character keys (a-z, 1-9, ...). If you need other key (like function keys), you'll need to use the keypress method.
See http://msdn2.microsoft.com/en-us/library/system.windows.forms.datagridviewcell.aspx for more info about th DataGridViewCell class.
Regards