很简单的委托与事件
using System;
using System.Drawing;
using System.Windows.Forms;
class Test
{
public delegate void PaintEventHandler(object objSend, PaintEventArgs pea);
public static void Main()
{
Form form=new Form();
form.Text="PaintEvent";
form.Paint += new PaintEventHandler(MyPaintEvent);
Application.Run(form);
MessageBox.Show("Application is return ","PaintEvent");
}
static void MyPaintEvent(object objSend, PaintEventArgs pea)
{
Graphics graphics=pea.Graphics;
graphics.Clear(Color.Chocolate);
}
}
form.Paint += new PaintEventHandler(MyPaintEvent);