定义委托和事件,并且触发这个事件
//定义委托 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; }