private void tabControl1_DrawItem(object sender, DrawItemEventArgs e)
{
int with = 0;
int x = 0;
for (int i = 0; i < tabControl1.TabPages.Count; i++)
{
with = tabControl1.TabPages[i].Bounds.Right;
}
StringFormat sf = new StringFormat();
sf.LineAlignment = StringAlignment.Center;
sf.Alignment = StringAlignment.Center;
Bitmap b = new Bitmap("G:\\1.jpg");
e.Graphics.DrawImage(b, e.Bounds); //给tabpage标题背景画图
Pen p = new Pen(Color.Black);
e.Graphics.DrawString(((TabControl)sender).TabPages[e.Index].Text, System.Windows.Forms.SystemInformation.MenuFont, new SolidBrush(Color.Black), e.Bounds, sf);
Rectangle endRec = tabControl1.GetTabRect(tabControl1.TabPages.Count - 1); //最后一个tabpage边框
Rectangle HeaderBackRect = new Rectangle(new Point(endRec.X + endRec.Width, endRec.Y),
new Size(tabControl1.Width - (endRec.X+endRec.Width), tabControl1.Height-tabControl1.TabPages[0].Bounds.Height)); //tabcontrol需要填充的矩形
e.Graphics.DrawImage(b, HeaderBackRect);
}
private void tabControl1_DrawItem(object sender, DrawItemEventArgs e)
最新推荐文章于 2023-02-22 15:02:54 发布