简单的paint事件处理程序

PaintEvent.cs
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方法。

posted @ 2011-01-08 21:21  ebusi2010  阅读(276)  评论(0编辑  收藏  举报