I have a particular column in a data grid which, when clicked, displays a
form with three text boxes on. I'm wanting to tab through these text boxes
but I'm having a bit of trouble because the data grid captures the tabs too.
I managed to get around it by putting the following on the form...
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.Tab)
{
if (textBox1.Focused)
textBox2.Focus();
else if (textBox2.Focused)
textBox3.Focus();
else
textBox1.Focus();
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
The problem that I'm having now is that when I press tab on textBox1 I get
an error message saying "Index 0 is not non-negative and below total rows
count. Do you want to correct the value?". I understand that this is because
the data grid is empty but if I put a message box directly above the "if
(textBox1.Focused)" line, when the text box closes it moves to textBox2
without any trouble. Also, if I put a breakpoint on "if (keyData ==
Keys.Tab)" and then click play as soon as the breakpoint is called it moves
on to textBox2 without any trouble.
The message box and the breakpoint are obviously doing something which is
stopping this error message from appearing. Does anyone know what it might be
and how I could replicate it myself to stop this error message from appearing?
Thanks,
Darrell