0

My program requires users to be able to right click a tab and then close it, but I can't do this when the right clicked tab doesn't select.

Any help would be nice, thanks.

1
Contributor
1
Reply
3
Views
6 Years
Discussion Span
Last Post by Jaydenn
0

I found a solution, here it is for anyone that needs this in the future:

private void tabControl_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                for (int i = 0; i < this.tabControl.TabCount; ++i)
                {
                    if (this.tabControl.GetTabRect(i).Contains(new Point(e.X, e.Y)))
                    {
                        this.tabControl.SelectedIndex = i;
                        break;
                    }
                }
            }      
        }
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.