读书人

很简单的嘱托与事件

发布时间: 2012-12-29 10:28:09 作者: rapoo

很简单的委托与事件


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);

这个提示无法将类型Test.PaintEventHandler隐性转换为System.Windows.Forms.PaintEventHandler;
怎么改,错哪了,更位大侠...谢谢哈..
[解决办法]
其实也很简单,你把public delegate void PaintEventHandler(object objSend, PaintEventArgs pea);删掉就可以了。

读书人网 >C++ Builder

热点推荐