void mainTC_MouseClick(object sender, MouseEventArgs e)
{
TabControl tc = sender as TabControl;
if (tc == null)
return;
if (e.Button != MouseButtons.Right)
return;
Point p = e.Location;
int current = -1;
for (int i = 0; i < tc.TabCount; i++)
{
Rectangle r = tc.GetTabRect(i);
if (r.Contains(p))
{
current = i;
break;
}
}
if (current != tc.SelectedIndex)
return; // didn't find the tab
ContextMenuTB.Show(tc, p);
}