前期工作:
加载资源文件,双击“Resources.resx"
类型选择Images
【添加资源】——【添加现有文件】
选择需要添加的图片文件,保存即可。
在下面的资源文件夹中即可看到添加的图片列表
**方法一:**重绘标签及背景
新建窗体,命名为"OtherForm.cs"
窗体布局如图:
将【tabControl】控件的【DrawMode】属性修改为”OwnerDrawFixed“
设计界面变为
tabControl控件的事件属性页,添加【DrawItem】事件
编辑【DrawItem】事件
private void tabControl2_DrawItem(object sender, DrawItemEventArgs e)
{
//加载背景图片
Image imgButton = Properties.Resources.p4;
Image imgBJ = Properties.Resources.p5;
//绘制主控件的背景
Rectangle Rect = new Rectangle(0, 0, this.tabControl2.Width, this.tabControl2.Height);
e.Graphics.DrawImage(imgBJ, Rect);
//新建一个StringFormat对象,用于对标签文字的布局设置
StringFormat stringFormat = new StringFormat();
stringFormat.LineAlignment = StringAlignment.Center; // 设置文字垂直方向居中
stringFormat.Ali