我在一个 picturebox 上用Graphics.DrawString("字符串A"),但现在 文字的内容改变了,我想清除"字符串A",换成"字符串B",请问各位高手,有什么办法
你應該有底圖的吧,如果字符串變了,那么就重新寫好啦
这个恐怕要了解图层的概念,把上面图层去掉,重新再写。
给你一个例子:
private void button1_Click(object sender, EventArgs e)//绘图
{
string drawString = "Test Text!";
Font drawFont = new Font("Arial", 16);
SolidBrush drawBrush = new SolidBrush(Color.Black);
PointF drawPoint = new PointF(10.0F, 10.0F);
Graphics g = pictureBox1.CreateGraphics();
g.DrawString(drawString, drawFont, drawBrush, drawPoint);
}
private void button2_Click(object sender, EventArgs e)//清除
{
pictureBox1.Image = null;
pictureBox1.Invalidate();
}