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

这段代码为什么不能正常绘制,该怎么处理

2012-03-17 
这段代码为什么不能正常绘制C# codeprotected override void OnPaint(PaintEventArgs e){base.OnPaint(e)

这段代码为什么不能正常绘制

C# code
        protected override void OnPaint(PaintEventArgs e)        {            base.OnPaint(e);            Graphics grfx = e.Graphics;            Rectangle rect = ClientRectangle;            rect.Inflate(new Size(-100, -100));            grfx.DrawRectangle(new Pen(Color.Black), rect);        }


一个简单的windows窗体应用程序,只重载了Form的OnPaint事件,可这段代码在窗体大小改变的时候不能正常工作。
哪位达人能告诉为什么?
晕乎了,谢谢~~ VS 2010

[解决办法]
下面这个页面或许对你有帮助
http://topic.csdn.net/t/20060325/11/4639197.html
[解决办法]
C# code
    public partial class Form1 : Form    {        public Form1()        {            InitializeComponent();            this.DoubleBuffered = true;        }        protected override void OnPaint(PaintEventArgs e)        {            base.OnPaint(e);            Rectangle rect = this.ClientRectangle;            rect.Inflate(-100, -100);            e.Graphics.DrawRectangle(Pens.Black, rect);        }        protected override void OnSizeChanged(EventArgs e)        {            base.OnSizeChanged(e);            this.Invalidate();        }    } 

热点排行