I want to add a close button to header of my TabPages. So, like browser tabs it can be removed from the TabControl. Thank you in advance for your time.
EDIT :
Now, I'm handling the closing with middle click like the code below but I want to provide my user with a friendly close button on the tabPage header.
private void tabControl1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button != System.Windows.Forms.MouseButtons.Middle)
return;
for (int i = 0; i < MainTabControl.TabPages.Count; i++)
{
if (this.MainTabControl.GetTabRect(i).Contains(e.Location))
{
this.MainTabControl.TabPages.RemoveAt(i);
return;
}
}
}
Edit
I found out that my question is repeated and correctly have answered there.