How to Handle DatagridView's keydown event during editing of cell
-
how can i handle Datagridview's Keydown Event after editing cell on Enter key Press datagridview have columns readonly=false and columns readonly=true need when i press enter key goto cell[6] of next row from any cell in previous row (====> this important one) and when i press tab from cell [4] call func and tab from other cells call another func
-
how can i handle Datagridview's Keydown Event after editing cell on Enter key Press datagridview have columns readonly=false and columns readonly=true need when i press enter key goto cell[6] of next row from any cell in previous row (====> this important one) and when i press tab from cell [4] call func and tab from other cells call another func
the answer :D
private const UInt32 WM_KEYDOWN = 0x0100;
public bool PreFilterMessage(ref Message m) { if (this.ActiveControl is DataGridViewTextBoxEditingControl) { if (m.Msg == WM\_KEYDOWN) { Keys keyCode = (Keys)(int)m.WParam & Keys.KeyCode; if (keyCode == Keys.Enter) { if (this.dgvReadInsert.CurrentCell.ColumnIndex == 4 || this.dgvReadInsert.CurrentCell.ColumnIndex == 10 || this.dgvReadInsert.CurrentCell.ColumnIndex == 6 || this.dgvReadInsert.CurrentCell.ColumnIndex == 12 || this.dgvReadInsert.CurrentCell.ColumnIndex == 13 || this.dgvReadInsert.CurrentCell.ColumnIndex == 14) this.dgvReadInsert.CurrentCell = this.dgvReadInsert\[6, this.dgvReadInsert.CurrentCell.RowIndex + 1\]; return true; } } return false; } return false; }
after inherit from class form1 : Form, IMessageFilter