如何在主窗体的toolStripButton1_Click事件就调用子窗体的ShowFilter事件
private void toolStripButton1_Click(object sender, EventArgs e)
{
//获得当前子窗体名
if (this.ActiveMdiChild != null)
{
MessageBox.Show(this.ActiveMdiChild.Name.ToString());
}}子窗体事件:
public void ShowFilter()
{
MessageBox.Show("sss");
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
//获得当前子窗体名
if (this.ActiveMdiChild != null)
{
MessageBox.Show(this.ActiveMdiChild.Name.ToString());
}}子窗体事件:
public void ShowFilter()
{
MessageBox.Show("sss");
}
{
//获得当前子窗体名
if (this.ActiveMdiChild != null)
{
MessageBox.Show(this.ActiveMdiChild.Name.ToString());
子窗体 subfrm = this.ActiveMdiChild as 子窗体;
if( subfrm != null ){
subfrm.ShowFilter();
}
}
} //子窗体事件:
public void ShowFilter()
{
MessageBox.Show("sss");
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
FromTian Tian = new FromTian();
Tian.MdiParent = this;
Tian.Tick();
}
子窗体方法
public void Tick()
{
MessageBox.Show("sdfasdfasdfa");
}
private void toolStripButton1_Click(object sender, EventArgs e)
{
if (this.ActiveMdiChild != null)
{
MessageBox.Show(this.ActiveMdiChild.Name.ToString());
//假设子窗体类型SubForm
if((this.ActiveMdiChild as SubForm) != null ){
(this.ActiveMdiChild as SubForm).ShowFilter();
}
}
} //子窗体事件:
public void ShowFilter()
{
MessageBox.Show("sss");
}