//定义一个代理和相应的事件,参数自己定义
public delegate void SomeDelegate(object args,...);
public event SomeDelegate OnSomeEvent;//引发事件:if (OnSomeEvent != null)
{
OnSomeEvent(args,...);
}
public delegate void SomeDelegate(object args,...);
public event SomeDelegate OnSomeEvent;//引发事件:if (OnSomeEvent != null)
{
OnSomeEvent(args,...);
}
http://community.csdn.net/Expert/topic/3744/3744086.xml?temp=.4815637
http://blog.csdn.net/zhzuo/archive/2004/11/30/199599.aspx
http://blog.csdn.net/zhzuo/archive/2004/04/02/22026.aspx
public class custClass
{
public event Turn turnOn;//定义事件,若要在事件框中显示提示要用到自定义信息public void Do(){}
{
if (turnOn!=null) turnOn();
}
}
public class my
{
public void KK()
{
MessageBox.Show("口口口口口");
}
public static void Main()
{
my a = new my();
custClass b = new custClass();
b.turnOn += new Turn(a.KK);
b.do();}
}
在朋友家上网,没有.net环境,可能还需要修改.
然后用这个代理声明一个事件event
在适当的时候引发这个事件的执行. 这时就可以在使用这个控件时找到相应的事件,然后添加处理代码了.
比如[Bindable(true), Category("Border Options"),
DefaultValue(System.Windows.Forms.Border3DStyle.Etched),
Description("Specifies the style of the three-dimensional border.")]
这个是在控制控件属性的例子.即在属性前面加上以上内容即可.至于事件,你可以查一下CSDN或是网上搜一下,不是很难的.
附:
bindable:一般不要加,因为默认就为true.好像是绑定到属性表的意思.
Category:属性所在属性栏的类别
DefaultValue:默认值.
Description:解释该控件属性的文字.
up
以上各位都已经说的很详细了