首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

DrawString后如何清除

2011-12-31 
DrawString后怎么清除?我想实时看水印效果privatevoidtextBox1_TextChanged(objectsender,EventArgse){Gra

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);
}

热点排行