如何實現光標在文本框的,數據庫的表格在按上下鍵時可以移動。就是下面這種情況。
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData == Keys.Down)
{
this.dataGridView1.Rows[this.dataGridView1.CurrentRow.Index + 1 > this.dataGridView1.Rows.Count ? this.dataGridView1.Rows.Count - 1 : this.dataGridView1.CurrentRow.Index + 1].Selected = true;
}
if (e.KeyData == Keys.Up)
{
this.dataGridView1.Rows[this.dataGridView1.CurrentRow.Index - 1 < 0 ? 0 : this.dataGridView1.CurrentRow.Index - 1].Selected = true;
}
}