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.

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;
                    }
                }
            }      
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.