第一步:设置Alignment=left
设置DrowMode=OwnerDrawFixed
设置ItemSize=30,100
设置SizeMode=Fixed
第二部:重绘,实现tabcontrol控件的tabControl1_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.DirectionRightToLeft);
sf.LineAlignment = StringAlignment.Center;
sf.Alignment = StringAlignment.Center;
e.Graphics.DrawString(text, SystemInformation.MenuFont,brush, e.Bounds, sf);
}
image.png
转自:https://blog.csdn.net/kasama1953/article/details/51546149
网友评论