I (I am fairly new at C#) ran into a problem which I have tried to solve myself but couldn't find a solution.
given: I have a Datagridview with 10 columns and x rows. (The column Headers reach from 1 to 10)
My Problem: I only need to write "1", "0" or "=" into the cells, but for more filling speed while using the Numpad I would like to automatically write a "=" into the current selected cell when I press 2 on the Numpad.
My Current solution (Which doesn't work):
private void dataGridView1_KeyPress(object sender, KeyPressEventArgs e)
{
if(e.KeyChar == '2'||e.KeyChar.ToString() == "2")
{
dataGridView1.Rows[dataGridView1.CurrentCell.RowIndex].Cells[dataGridView1.CurrentCell.ColumnIndex].Value = "=";
}
}
I have tried it with cellLeave and cellstatchanged but it doesn't work.