EL-Prince
EL-Prince

Reputation: 21

How to focus a certain tabpage when it rightclicked?

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

Upvotes: 2

Views: 1022

Answers (1)

Hans Passant
Hans Passant

Reputation: 941267

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;
                }
            }
        }
    }

Upvotes: 1

Related Questions