简单的paint事件处理程序
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 using System;
2 using System.Drawing;
3 using System.Windows.Forms;
4
5 class PaintEvent
6 {
7 public static void Main()
8 {
9 Form form = new Form();
10 form.Text = "Paint Event";
11 form.Paint += new PaintEventHandler(MyPaintHandler);
12
13 Application.Run(form);
14 }
15 static void MyPaintHandler(object objSender, PaintEventArgs pea)
16 {
17 Graphics grfx = pea.Graphics;
18
19 grfx.Clear(Color.Chocolate);
20 }
21 }
注意:覆盖了OnMove方法和OnResize方法。