DrawString后怎么清除?
我想实时看水印效果
private void textBox1_TextChanged(object sender, EventArgs e)
{
Graphics dc = Graphics.FromImage(this.pictureBox1.Image);
dc.DrawString(this.textBox1.Text, new Font( "新宋体 ", 32), Brushes.Red, 24, 26);
//dc.Clear();
//dc.d
dc.Dispose();
this.pictureBox1.Invalidate();
}
可是水印打上去在打是重叠的
怎么样打上去在修改文字的时候能把先前的去掉
在打上修改后的文字
------解决方案--------------------private void textBox1_TextChanged(object sender, System.EventArgs e)
{
Graphics dc = Graphics.FromImage(this.pictureBox1.Image);
dc.Dispose();
this.pictureBox1.Invalidate(pictureBox1.ClientRectangle);
}
private void pictureBox1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Graphics dc =e.Graphics;
dc.DrawString(this.textBox1.Text, new Font( "新宋体 ", 32), Brushes.Red, pictureBox1.ClientRectangle);
}