views:

16

answers:

1

How to select or focus a certain tabpage when it right clicked?

+1  A: 

Implement the MouseDown event and find out what tab got clicked:

    private void tabControl1_MouseDown(object sender, MouseEventArgs e) {
        if (e.Button == MouseButtons.Right) {
            for (int tab = 0; tab < tabControl1.TabCount; ++tab) {
                if (tabControl1.GetTabRect(tab).Contains(e.Location)) {
                    tabControl1.SelectedIndex = tab;
                    break;
                }
            }
        }
    }
Hans Passant
Personally I would recommend to use the `MouseDown` event instead. Why should the right mouse button behave so drastically differently from the left?
Timwi
Okay, I agree .
Hans Passant