Reputation: 873
I want to be able to middle click the tab on a TabPage
and have it removed from the TabControl
but even with HotTracking turned on, I don't know how to capture which tab I middle clicked on.
Is there a way to do that?
Upvotes: 1
Views: 200
Reputation: 232
You could do something like this on the MouseClick
event of your TabControl
:
private void tabControl_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Middle)
{
for (int i = 0; i < tabControl.TabCount; i++)
{
if (tabControl.GetTabRect(i).Contains(e.Location))
{
tabPaControl.TabPages[i].Dispose();
}
}
}
}
Upvotes: 3