定義委託和事件,而且觸發這個事件spa
//定義委託 public delegate void ShowOutStockDelegate(List<OutStockResultDto> outStockResultDto); //定義事件 public event ShowOutStockDelegate ShowOutStockEvent; private void btnConfirm_Click(object sender, EventArgs e) { ShowOutStockEvent(outStockResultDtos); }
在目標窗體上,實例化上述窗體code
FrmEndTask frmEndTask = new FrmEndTask(); //觸發這個事件 frmEndTask.ShowOutStockEvent += new FrmEndTask.ShowOutStockDelegate(EndTask_ShowOutStockEvent); protected void EndTask_ShowOutStockEvent(List<OutStockResultDto> outStockResultDtos) { //這裏就能拿到你想要的數據了 _outStockResultDtos = outStockResultDtos; }