如何控制按tab在datagridview跳动
如何控制按tab在datagridview跳动
[解决办法]
- C# code
private void dataGridView1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Tab) e.Handled = true; }
[解决办法]
- C# code
private void dataGridView1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { if (e.KeyCode == Keys.Tab) { int row = this.dataGridView1.CurrentCell.RowIndex; int cel=this.dataGridView1.CurrentCell.ColumnIndex; row = (row + 2) % this.dataGridView1.Rows.Count; this.dataGridView1.CurrentCell = this.dataGridView1.Rows[row].Cells[cel]; } }