C# 、子窗体调用父窗体属性、方法

时间:2024-09-20 10:36:08
 namespace Test
{
public partial class FrmMain : Form
{
public FrmMain()
{
InitializeComponent();
}
public DataTable DT;
private void button1_Click(object sender, EventArgs e)
{
FrmChild fm = new FrmOptime(this);
fm.Show();
}
public void BindData(){}
}
}

主窗体

 namespace Test
{
public partial class FrmChild : Form
{
public FrmChild ()
{
InitializeComponent();
}
FrmMain frmMain;
public FrmChild (FrmMain fm)
{
InitializeComponent();
frmMain = fm;
}
private void button1_Click(object sender, EventArgs e)
{
frmMain.RemnantDT;
frmMain.BindData();
}
}
}

子窗体