怎样获取主窗体的对象??? 我想在不是主窗体的窗体里获取主窗体的实例,就是可以用一个主窗体的类的实例来表示主窗体,怎么做啊???小弟不才 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public partial class Form1 : Form { public Form1() { InitializeComponent(); } public string TextBox1Text { set { this.textBox1.Text = value; } get { return this.textBox1.Text; } } private void button1_Click(object sender, EventArgs e) { Form2 frm2 = new Form2(); frm2.Show(this); } } public partial class Form2 : Form { public Form2() { InitializeComponent(); } private void button2_Click(object sender, EventArgs e) { Form1 frm1 = (Form1)this.Owner; frm1.TextBox1Text = this.textBox2.Text; this.Close(); } } 你可以通过子窗体的构造函数把主窗体的对象传过去,这样获取到得就不是NEW出来的对象了 4楼的可以实现,有一点看不懂private void button1_Click(object sender, EventArgs e) { Form2 frm2 = new Form2(); frm2.Show(this); } 打开第2个窗口的时候你把第一个窗口的本身传过去了,但第2个窗口的构造函数是没参,他是怎么接收到那个对象的新人请高手不要笑我 frm2.Show(this); ------this为form1的指针, form2.show(this);函数把form1的指针保存在form2的owner属性中 求助(C#中,怎么更新数据库中的内容) 请问,下图效果如何做? 怎么调试这个C++ COM组件呢? C#新建Excel文件,并添加VBA宏代码、运行VBA宏代码 数据层访问的几个问题。 求助:关于StreamWrite向txt文件写数据的问题 c#打印输出问题,急在线等...谢谢先 如何关闭子窗体? CSDN朋友下载VS。NET 2003又一好消息 C#刷新页面问题 急,急,将页面加到iframe中怎么设置? avicap32.dll怎样设置和获取视频源及亮度等参数(不使用对话框)
{
public Form1()
{
InitializeComponent();
} public string TextBox1Text
{
set { this.textBox1.Text = value; }
get { return this.textBox1.Text; }
} private void button1_Click(object sender, EventArgs e)
{
Form2 frm2 = new Form2();
frm2.Show(this);
}
} public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
} private void button2_Click(object sender, EventArgs e)
{
Form1 frm1 = (Form1)this.Owner;
frm1.TextBox1Text = this.textBox2.Text;
this.Close();
}
}
private void button1_Click(object sender, EventArgs e)
{
Form2 frm2 = new Form2();
frm2.Show(this);
}
打开第2个窗口的时候你把第一个窗口的本身传过去了,但第2个窗口的构造函数是没参,他是怎么接收到那个对象的
新人请高手不要笑我
------
this为form1的指针, form2.show(this);函数把form1的指针保存在form2的owner属性中