zoukankan      html  css  js  c++  java
  • winform使用委托和事件在窗体之间传值

    定义委托和事件,并且触发这个事件

         //定义委托
            public delegate void ShowOutStockDelegate(List<OutStockResultDto> outStockResultDto);
            //定义事件
            public event ShowOutStockDelegate ShowOutStockEvent;
            private void btnConfirm_Click(object sender, EventArgs e)
            {
                 ShowOutStockEvent(outStockResultDtos);
            }

    在目标窗体上,实例化上述窗体

    FrmEndTask frmEndTask = new FrmEndTask();
    //触发这个事件
    frmEndTask.ShowOutStockEvent += new FrmEndTask.ShowOutStockDelegate(EndTask_ShowOutStockEvent);
    protected void EndTask_ShowOutStockEvent(List<OutStockResultDto> outStockResultDtos)
    {
     //这里就能拿到你想要的数据了
    _outStockResultDtos = outStockResultDtos;
    }

      

  • 相关阅读:
    第8周课下作业1(补)
    第八章课下测试
    POJ
    POJ
    HDU
    UVa
    UVa
    CodeForces
    ZOJ
    LightOJ
  • 原文地址:https://www.cnblogs.com/siyunianhua/p/10886746.html
Copyright © 2011-2022 走看看