我有我的自定义按钮:
public partial class RaiseEvent : Button
{
public RaiseEvent()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{}
}
我需要像这样更改签名:
private void button1_Click(object sender, CatchEvent e)
{}
完整编辑:我有一个 DLL,其中有 2 个类,一个用于 customEvent 的 CatchEvent:
public class CatchEvent : EventArgs
{
public double data = 0;
public CatchEvent(double value)
{
data = value;
}
public EventEnergy
{
get { return this.data}
}
}
还有一类Calcul:
public class Calcul
{
public delegate void EventHandler(object sender, CatchEvent e);
public event EventHandler<CatchEvent> NewData;
public void Event(double value, byte[] data)
{
//some calculs = double result
OnRaiseCustomEvent(new CatchEvent(result));
}
public virtual void OnRaiseCustomEvent (CatchEvent e)
{
raiseEvent(this.e);
}
在我的表格的评论中提出建议:
public button1_Click (object sender, EventArgs e)
{
double data = //i try to recover value from my class CatchEvent without legacy
CatchEvent ce = new CatchEvent(data)
textBox1.Text = ce.data.Tostring();
}
public Form1(Calcul pub)
{
pub.NewData += button1; //doesnt work
}
所以我的最后一个问题是从我的类 CatchEvent 中恢复价值,而没有类遗产。谢谢你的帮助!