0
我想画在紧凑的框架自定义按钮,在“的OnPaint”功能我做这样的事情:在紧凑框架中居中对齐文本?
protected override void OnPaint(PaintEventArgs e)
{
System.Drawing.Imaging.ImageAttributes a = new
System.Drawing.Imaging.ImageAttributes();
e.Graphics.DrawImage(pictureBox1.Image, new Rectangle(0, 0, Width, Height),
0, 0, Image.Width, Image.Height, GraphicsUnit.Pixel, a);
Brush b = new SolidBrush(Color.Black);
e.Graphics.DrawString(Text, Font, b, 0, 0, (
new StringFormat(StringFormatFlags.NoWrap)));
}
这段代码的字体抽取所控制的左上角(如预期)。
我的问题是,我怎样才能得到它在控制中心?