Reputation: 21
How to select or focus a certain tabpage when it right clicked?
Upvotes: 2
Views: 1022
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