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
2010-08-23 23:57:45
Personally I would recommend to use the `MouseDown` event instead. Why should the right mouse button behave so drastically differently from the left?
Timwi
2010-08-24 00:03:46
Okay, I agree .
Hans Passant
2010-08-24 00:30:41