子窗体调用父窗体方法
你父窗体
public partial class MainForm1 : Form
{
public MainForm1()
{
InitializeComponent();
}
private void CreateFormInstance(string formName)
{
try
{
bool flag = false;
//遍历主窗口上的所有子菜单
for (int i = 0; i < this.MdiChildren.Length; i++)
{
// 如果所点的窗口被打开则重新激活
if (this.MdiChildren[i].Tag.ToString().ToLower() == formName.ToLower())
{
this.MdiChildren[i].Activate();
this.MdiChildren[i].Show();
this.MdiChildren[i].WindowState = FormWindowState.Normal;
flag = true;
break;
}
}
if (!flag)
{
//如果不存在则用反射创建form窗体实例。
Assembly asm = Assembly.Load("GZCRB");//程序集名
object frmObj = asm.CreateInstance(formName);//程序集+form的类名。
DockContent frms = (Form)frmObj as DockContent;
//tag属性要重新写一次,否则在第二次的时候取不到。原因还不清楚。有知道的望告知。
frms.Tag = formName.ToString();
frms.MdiParent = this;
frms.Show(dockPanel1);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
}
}
}
MainForm1 的this.IsMdiContainer = true;
子窗体from2怎么调用 MainForm1中 CreateFormInstance()方法
public partial class MainForm1 : Form
{
public MainForm1()
{
InitializeComponent();
}
private void CreateFormInstance(string formName)
{
try
{
bool flag = false;
//遍历主窗口上的所有子菜单
for (int i = 0; i < this.MdiChildren.Length; i++)
{
// 如果所点的窗口被打开则重新激活
if (this.MdiChildren[i].Tag.ToString().ToLower() == formName.ToLower())
{
this.MdiChildren[i].Activate();
this.MdiChildren[i].Show();
this.MdiChildren[i].WindowState = FormWindowState.Normal;
flag = true;
break;
}
}
if (!flag)
{
//如果不存在则用反射创建form窗体实例。
Assembly asm = Assembly.Load("GZCRB");//程序集名
object frmObj = asm.CreateInstance(formName);//程序集+form的类名。
DockContent frms = (Form)frmObj as DockContent;
//tag属性要重新写一次,否则在第二次的时候取不到。原因还不清楚。有知道的望告知。
frms.Tag = formName.ToString();
frms.MdiParent = this;
frms.Show(dockPanel1);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
}
}
}
MainForm1 的this.IsMdiContainer = true;
子窗体from2怎么调用 MainForm1中 CreateFormInstance()方法
...全文
相关推荐
js 子窗体调用父窗体中的方法
本篇将详细讲解如何使用JavaScript实现子窗体调用父窗体中的方法。首先,了解一些基本概念:1. **父窗口(Parent Window)**:打开子窗口的原始窗口。2.
简单的Factory 父窗体调用子窗体里的方法 树加载控件
属性公开:子窗体可以定义公共属性,包含需要调用的方法。父窗体通过设置这个属性,间接调用子窗体的方法。3. 使用引用:父窗体可以直接持有子窗体的引用,然后直接调用其公开的方法。
c# winform 用子窗体刷新父窗体,子窗体改变父窗体控件的值
**通过方法传递**:子窗体调用父窗体提供的方法,将新值作为参数传入,由父窗体来更新控件的值。
jQuery实现iframe父窗体和子窗体的相互调用
在处理父窗体和子窗体的相互调用时,我们常用的是JavaScript中的window对象的属性和方法。通过获取iframe中的window对象,我们可以访问其内部的变量和函数。
子窗体调父窗体
当需要从子窗体调用父窗体的方法或改变其状态时,可以通过以下几种方式实现:1. 传递引用:在创建子窗体实例时,可以将父窗体的引用作为参数传入子窗体,使得子窗体可以直接访问父窗体的方法和属性。2.


