GDI+ drawing text on specified coordinates on a form
can someone please give me a c# example 开发者_运维知识库of drawing a string using GDI+ on specified coordinates?
btw i apologize for the banner advertisement above this post, i am not responsible for posting it
The simplest way is to override the OnPaint method:
public class Form1
{
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.DrawString("MyString", new Font("Comic Sans MS", 12.0f), new SolidBrush(Color.Red), new PointF(50.0f, 50.0f));
}
}
This will draw "MyString" in red at 50,50.
精彩评论