RT 在主窗体中 用了如下代码
ChildFormf childform=new ChildForm();
childform.ShowDialog();
现在想在childfomr类里调用主窗体的引用。有什么方法。
ChildFormf childform=new ChildForm();
childform.ShowDialog();
现在想在childfomr类里调用主窗体的引用。有什么方法。
解决方案 »
- C # 数据结构
- 绑定datagridview时总是激发dataGridView1_SelectionChanged事件,有什么方法避免么?
- vs2010中使用mschart,如何实现点击曲线中的点为其设置标记??(Winform)
- IIS发布网站出错
- C#写Windows服务的时候,里面可以新建Form吗?
- C#语言写的希尔排序和堆排序,请高手指点
- 100分求教各位高手这个存储过程要怎样写!!?????????????不胜感激!!!!!!!!!!!!!!!!!!!!
- 急!!!!!!!!!!!!!如何在winform程序中设置和获取cookie变量呢?
- public class类里面怎么使用Form1上的控件?谢谢了
- 如何求任意多个数组的交集?在线等高手
- 新手的我,写的一个数据库类(单例模式),大家来找错,谢谢。
- 有没有系统讲讲C#在企业应用中的优缺点的资料????
{
Form2 frm=new Form2();
frm.Show(this);
}
public Form2
{
Form1 frm=this.Owner;}
ChildFormf中:
public string GetText()
{
//...
}
主窗体中:
ChildFormf childform=new ChildForm();
if (childform.ShowDialog() == DialogResult.OK)
{
this.Text = childform.GetText();
}
ChildFormf中:
//构造函数
private Form _Form;
public void ChildFormf(Form form)
{
_Form = form;
//...
}
public void OtherMethod()
{
//这里就可以访问_Form了。
}
主窗体中:
ChildFormf childform=new ChildForm(this);
childform.ShowDialog();
要引用的窗体:Form1,当前窗体Form2
在Form2中写 Form1 f1=new Form1();
然后窗体form1 里面的东西就可以引用了,关键是一定要设成public,默认是private