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)));
}
這段代碼的字體抽取所控制的左上角(如預期)。
我的問題是,我怎樣才能得到它在控制中心?