20180709001 - 委托传值

Main  :  Frm_MRP_P

Sub   :  Frm_SO_S_Selected

 

 

Frm_SO_S_Selected

    public partial class Frm_SO_S_Selected : Form
    {
        //声明委托
        public delegate void TransfDelegate(DataSet ds);
        //声明事件
        public event TransfDelegate TransfEvent;

        // List
        private void btn_List_Click(object sender, EventArgs e)
        {
                MRP.Frm_MRP_P Frm_MRP_P = new MRP.Frm_MRP_P();
                //Frm_MRP_P.MRP_P_DataSet108 = DataSet2.Copy();

                //触发事件  //此处调用你的取数据的方法,将数据付给ds
                TransfEvent(DataSet2);
                this.Hide();
        }

 

//-----------------------------------

Frm_MRP_P

    public partial class Frm_MRP_P : Form
    {

        // search
        private void btn_search_Click(object sender, EventArgs e)
        {           

            sales.Frm_SO_S_Selected SO_S_Selected = new sales.Frm_SO_S_Selected();
            SO_S_Selected.TransfEvent += new sales.Frm_SO_S_Selected.TransfDelegate(frm_TransfEvent);
            SO_S_Selected.ShowDialog();
        }

        private void frm_TransfEvent(DataSet ds)
        {
            //this.dataGridView1.DataSource = ds.Tables[0]; //此处就是你给DataGridView绑定数据的方法
            if (ds != null)
            {
                dgv_M.DataSource = ds.Tables[0];
            }
            else
            {
                dgv_M.Focus();
            }
        }

 

posted @ 2018-07-09 13:51  追逐苦痛  阅读(221)  评论(0编辑  收藏  举报