I wants to focus on datagridview's particulars cells on pressing Keys Shift+Tab from textbox1 KeyDown Event like below:
if (e.KeyCode == Keys.Tab && e.Shift)
{
int i = mydgv.Rows.Count - 1;
mydgv.CurrentCell = mydgv.Rows[i].Cells[1];
}
But it's not works. I also try mydgv.Rows[i].Cells[1].Selected = true; and textbox1 KeyUp Event but it's not works.
Is there any better way to focus on datagridview's particulars cell from textbox's KeyDown/KeyUp event like above?.
FroglegPosted May 17, 2012, 12:16 PM
I chose the control key as being the best key for your situation
mahesh waghelaPosted May 17, 2012, 7:56 AM
FroglegPosted May 17, 2012, 5:10 AM
bool ctrlDown = false;
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.ControlKey )
{
ctrlDown = true;
}
}
private void Form1_KeyUp(object sender, KeyEventArgs e)
{
if (ctrlDown && e.KeyCode == Keys.D)
{
ctrlDown = false;
int i = dataGridView1.Rows.Count - 1;
dataGridView1.CurrentCell = dataGridView1.Rows[i].Cells[i];
}
}