问题描述
namespaceWindowsFormsApplication1{publicpartialclassForm1:Form{Graphicsg;Rectanglere;Penmypen=newPen(Color.Red,5);publicForm1(){InitializeComponent();g=this.CreateGraphics();re=newRectangle(50,50,50,50);}publicvoidPaint(objectsender,PaintEventArgse){g.DrawRectangle(mypen,re);}}}
解决方案
解决方案二:
你的Paint方法跟Form的Paint事件绑定了么?this.Paint+=newSystem.Windows.Forms.PaintEventHandler(this.Paint);
时间: 2024-09-17 04:00:16