private void tabControl1_DrawItem(object sender, DrawItemEventArgs e)

 

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);
        }


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值