C# disable arrow navigation with tabcontrol

conkeyuptabcontrolvisual-studio-2008winforms

I have a tabcontrol in my form, and I need to use the keyup event to manage somethings.

When I press left or right button, the tab page change, and I wish to disable the tabcontrol keyboard navigation.

it's possible to do this?

Best Answer

You don't need to extend TabControl, just subscribe to its KeyDown event and handle it.

tabControl1.KeyDown+=new KeyEventHandler(tabControl1_KeyDown);

private void tabControl1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Left || e.KeyCode == Keys.Right)
            {
                e.Handled = true;
            }
        }

tabControl1 doesn't change pages. KeyUp of the form and tabControl1 fires normally.