C#中子窗体向主窗体传递参数

子窗体

 //定义委托
        public delegate void Showding(UserControl ss);
        // 声明事件

        public event Showding Showding1;



        // 调用事件函数

        public void OnDataChange(UserControl ss)
        {

            if (Showding1 != null)
            {

                Showding1(ss);

            }

        }


private void datagridview1_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (this.datagridview1.CurrentRow != null)
            {
                if (this.datagridview1.CurrentCell.ColumnIndex > 0)
                {
                    xiaoding din = new xiaoding(this.datagridview1.CurrentRow.Cells[1].Value.ToString());
                    OnDataChange(din);
                }
            }
        }

主窗体

private void buttonItem3_Click(object sender, EventArgs e)
		{
            Xiaolie xiaolie = new Xiaolie();
            xiaolie.Dock = DockStyle.Fill;
            xiaolie.Showding1 += new Xiaolie.Showding(DataChanged);
         
		}
        public void  DataChanged(UserControl ss)
        {

            ss.Dock = DockStyle.Fill;
            //this.pClass.TabControlAttachedControl("销售订单", this.tabControl1, ss);

        }

 

你可能感兴趣的:(C#中子窗体向主窗体传递参数)