DayLaborer
Programmer
The user of my app wants the "enter" key to function like the "tab" key, e.g. to navigate from field to field. I found a good idea here:
The problem is that although clicking the tab key itself will take me from textbox to textbox, when I use the method mentioned above, it stops on Labels, too.
I tried something like this:
...but it didn't work.
How can I get around this?
Thanks,
Eliezer
The problem is that although clicking the tab key itself will take me from textbox to textbox, when I use the method mentioned above, it stops on Labels, too.
I tried something like this:
Code:
private void General_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
Control nextControl = this.GetNextControl(ActiveControl, true);
if (nextControl != null)
{
e.Handled = true;
if (!(nextControl is Label))
{
nextControl.Focus();
}
else //the next control is currently a label
{
nextControl = this.GetNextControl(ActiveControl, true);
while (nextControl != null)
{
nextControl.Focus();
if (!(nextControl is Label))
{
break;
}
nextControl = this.GetNextControl(ActiveControl, true);
}
}
}
}
}
How can I get around this?
Thanks,
Eliezer