首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ Builder >

很简单的委托与事件解决方案

2012-02-04 
很简单的委托与事件C# codeusing Systemusing System.Drawingusing System.Windows.Formsclass Test{pu

很简单的委托与事件

C# code
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);    }}



C# code
form.Paint += new PaintEventHandler(MyPaintEvent);

这个提示无法将类型Test.PaintEventHandler隐性转换为System.Windows.Forms.PaintEventHandler;
怎么改,错哪了,更位大侠...谢谢哈..

[解决办法]
其实也很简单,你把public delegate void PaintEventHandler(object objSend, PaintEventArgs pea);删掉就可以了。

热点排行