开发者

GDI+ drawing text on specified coordinates on a form

开发者 https://www.devze.com 2023-01-04 20:11 出处:网络
can someone please give me a c# example 开发者_运维知识库of drawing a string using GDI+ on specified coordinates?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消