I have a form with a datagridview and when user start entering value for first cell in first row , , can also press f2 which submit that value , but i cant access cell value unless user hit tab and go to another cell
following is my code for accessing cell value when f2 is hit
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
var key = new KeyEventArgs(keyData);
ShortcutKey(this, key);
return base.ProcessCmdKey(ref msg, keyData);
}
protected virtual void ShortcutKey(object sender, KeyEventArgs key)
{
switch (key.KeyCode)
{
case Keys.F2:
MessageBox.Show(dataGridView1.SelectedCells[0].Value.ToString());
break;
}
}
dataGridView1.SelectedCells[0].Value returns null