日期:2014-05-18  浏览次数:20869 次

如何控制按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];

            }
        }