代码如下private void Form1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.SetClip(this.ClientRectangle);
System.Diagnostics.Debug.WriteLine("ClientRectangle region painted: " + this.ClientRectangle);
System.Diagnostics.Debug.WriteLine("Clipping region painted: " + e.ClipRectangle);
Pen pen = new Pen(Color.Red);
e.Graphics.DrawLine(pen, 0, 0, 60, 120);
e.Graphics.DrawRectangle(pen, e.ClipRectangle);
pen.Dispose();
System.Diagnostics.Debug.WriteLine("Clipping region painted: " + e.ClipRectangle);
}如果该窗口是可以滚动的,当点击滚动条时,SetClip方法不起作用,不知谁知道为什么???
{
e.Graphics.SetClip(this.ClientRectangle);
System.Diagnostics.Debug.WriteLine("ClientRectangle region painted: " + this.ClientRectangle);
System.Diagnostics.Debug.WriteLine("Clipping region painted: " + e.ClipRectangle);
Pen pen = new Pen(Color.Red);
e.Graphics.DrawLine(pen, 0, 0, 60, 120);
e.Graphics.DrawRectangle(pen, e.ClipRectangle);
pen.Dispose();
System.Diagnostics.Debug.WriteLine("Clipping region painted: " + e.ClipRectangle);
}如果该窗口是可以滚动的,当点击滚动条时,SetClip方法不起作用,不知谁知道为什么???
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货