コンパクトなフレームワークでカスタム ボタンを描画しようとしています。「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)));
}
このコードでは、フォントがコントロールの左上隅に描画されます (予想どおり)。
私の質問は、コントロールの中心に描画するにはどうすればよいですか?