Search code examples
c#comboboxtextboxrhinoceros

Can't tab through combo and textboxes


I am currently working with an API for a program called Rhinoceros. The program does not allow tabbing through Forms so I am trying to program it in. It works well how I have it, however, when I try to tab from a combobox to a textbox or vice versa the cursor doesn't move. I have tried the select() and focus() function, neither seem to work and I am currently trying SelectNextControl but I cannot seem to get it to work either. If you have any ideas please let me know, anything is helpful.

private void cbNPProjectFolder_KeyDown(object sender, KeyEventArgs e)
{
  if(e.KeyData == Keys.Tab)
  {
    txtbxNPProjectNum.SelectNextControl(sender as Control, true, false, true, true);
    e.Handled = true;
    e.SuppressKeyPress = true;
  }
}

Solution

  • I ended up figuring it out, If anyone else has this problem:

    I selected all of the containers I wanted to tab through, went to events on the bottom right, in the KeyDown box I named it Generic_KeyDown.

     private void Generic_KeyDown(object sender, KeyEventArgs e)
            {
                if(e.KeyCode == Keys.Tab)
                {
                    e.Handled = true;
                    this.SelectNextControl((Control)sender, true, true, true, true);
                    e.SuppressKeyPress = true;
                }
            }