C# winfrom Tabcontrol 控件设置纵向显示、并重绘标题名称

第一步:设置Alignment=left//设置纵向靠左显示

              设置DrowMode=OwnerDrawFixed//设置为用户绘制标题

              设置ItemSize=30,120//可选

              设置SizeMode=Fixed//可选

第二步:重写DrawItem事件

private void tabControl1_DrawItem(object sender, DrawItemEventArgs e)
        {
            string text = ((TabControl)sender).TabPages[e.Index].Text;
            SolidBrush brush = new SolidBrush(Color.Black);
            StringFormat sf = new StringFormat(StringFormatFlags.DirectionVertical);
            sf.LineAlignment = StringAlignment.Center;

            sf.Alignment = StringAlignment.Center;

            e.Graphics.DrawString(text, SystemInformation.MenuFont, brush, e.Bounds, sf);
        }

  

猜你喜欢

转载自www.cnblogs.com/wsxaccount/p/9023783.html