窗体间要相互传递数据时,比如在ERP系中常见单据流中的数据传递,可设计窗体中的数据变量的访问属性为public
/// <summary> /// 双击表格行穿透查询到单据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dataGridView1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex > -1) { var voucherNo = this.dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString(); Frm_income frm_income = new Frm_income(); string tabPageText = frm_income.Text; Utility.UI.EmbedForm embedForm = new Utility.UI.EmbedForm(); //使用母窗体的属性信息,实现动态创建插入页签式窗体 embedForm.openForm(frm_income, tabPageText, (TabControl)this.Parent.Parent.Parent.Controls["tabControl1"], (Panel)this.TopLevelControl.Controls["panel1"]); ToolStrip t = (ToolStrip)frm_income.Controls["ts_income"]; frm_income.tsb_query.PerformClick(); frm_income.rtxt_voucherNO.Text = voucherNo; frm_income.btn_query.PerformClick(); } }