Scenes
Delegate in C # using the event - by value across Winform form in an example:
https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/100150700
When transfer is defined above with reference to the event parameter is a simple string, if the parameters to be passed more complex, it can be encapsulated using the object parameters.
Blog home page:
https://blog.csdn.net/badao_liumang_qizhi
public concern number of
programs overbearing ape
acquisition-related programming e-books, tutorials and push for free download.
achieve
A delegate in the form of defined events
public delegate void RefreshChartInOneDelegete(XYModel xYModel); public static event RefreshChartInOneDelegete OnRefreshChartInOne;
Wherein the package is their XYModel parameters Model, according to needs its own specific packaging.
public class XYModel { // store the X-axis property Private XAxisModel xAxisModel; // store Y axes attributes Private List <YAxisModel> yAxisModelList; public XAxisModel XAxisModel { get { return xAxisModel; } set { xAxisModel = value; } } public List<YAxisModel> YAxisModelList { get { return yAxisModelList; } set { yAxisModelList = value; } } }
Define the trigger
xYModel.YAxisModelList = yAxisModelList; if (OnRefreshChartInOne != null) { OnRefreshChartInOne(xYModel); }
Then subscribe to events in the form B
FrmChartOptionInOneCurCom.OnRefreshChartInOne += new FrmChartOptionInOneCurCom.RefreshChartInOneDelegete(ChartCompareHelper_OnRefreshChart);
Write the specific implementation in the form B
private void ChartCompareHelper_OnRefreshChart(XYModel xYModel) { xYModelStore = xYModel; ChartCompareHelper.RefreshPaneComInOne(this.zedGraphControl1,xYModel.YAxisModelList); }