views:

26

answers:

0

This is a C# WinForms app:

A TabControl by default will change tabs when the Control+PageUp or PageDown keys are pressed.

How do I prevent this behavior?

I've tried to handle the event as follows, but the control changes tab pages anyway:

    private void tabControl_KeyDown(object sender, KeyEventArgs e)
    {
        if (ModifierKeys != Keys.Control) return;
        if (e.KeyCode == Keys.PageUp || e.KeyCode == Keys.PageDown)
            e.Handled = true;
    }