我在Google上搜索了“在PictureBox上绘制文本C#”,但是没有找到有用的东西。然后我又搜索了“在Form上绘制文本C#”,找到了一些代码,但它的工作方式与我想要的不同。
private void DrawText()
{
Graphics grf = this.CreateGraphics();
try
{
grf.Clear(Color.White);
using (Font myFont = new Font("Arial", 14))
{
grf.DrawString("Hello .NET Guide!", myFont, Brushes.Green, new PointF(2, 2));
}
}
finally
{
grf.Dispose();
}
}
当我调用这个函数时,表单的背景颜色变成了白色(默认情况下是黑色)。
我的问题:
1:这对PictureBox起作用吗?
2:如何解决这个问题?