Hi,
Use Rectangle imageRect = new Rectangle(e.Bounds.X + 4, e.Bounds.Y + 4, 16, 16) to modify the image position
tabControl1_DrawItem:
TabPage tabPage = tabControl1.TabPages[e.Index];
// Get the current tab page's text
string title = this.tabControl1.TabPages[e.Index].Text;
// Get the current tab page's image
Image image = closeImage;
Rectangle r = e.Bounds;
r = this.tabControl1.GetTabRect(e.Index);
r.Offset(2, 2);
// Set the bounds for the image
Rectangle imageRect = new Rectangle(e.Bounds.X + 4, e.Bounds.Y + 4, 16, 16);
Brush TitleBrush = new SolidBrush(Color.Black);
e.Graphics.FillRectangle(new SolidBrush(Color.CadetBlue),e.Bounds );
// Draw the image and text
if (image != null)
e.Graphics.DrawImage(image, imageRect);
e.Graphics.DrawString(title, this.Font, TitleBrush, new PointF(r.X + 22, r.Y + 2));
private void tabControl1_MouseClick(object sender, MouseEventArgs e)
{
tabControl1.TabPages.Remove(tabControl1.SelectedTab);
}
change the color of the tab cover header
Do you mean the color of tabpage?
e.Graphics.FillRectangle(new SolidBrush(Color.CadetBlue),e.Bounds );
Best regards,
Minxin Yu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.