所以这里的故事,我有三个表格和两个班级,我目前有信息被发送到form1就好了。现在,当我尝试将数据从同一个类(或另一个)发送到form2时,public event Action<string> updateMainLabelconn;
返回null。
这是我正在尝试的策略,是与form1交谈时的工作方式:
public class Connection
{
public Form2 form2;
public event Action<string> updateMainLabelconn;
//There is other methods that call to this method and it works correctly.
public void LE1_Update(object sender, InstrumentLookupSubscriptionEventArgs e)
{
updateMainLabelconn("INSTRUMENT LOADED : " + e.Instrument.InstrumentDetails.Name.ToString());
}
}
public partial class Form2 : Form
{
public Connection conn;
public Form2()
{
InitializeComponent();
conn = new Connection();
conn.updateMainLabelconn += MainStatusUpdateconn;
}
public void MainStatusUpdateconn(string e)
{
mainStatus.Text = e;
}
所以,这是代码的关键部分,我想,如果我错过了什么,那么随意扯我一个新的!哈哈