两窗体间调用控件,就是显示不出赋的值,请老师指点一下,谢谢
发表在C#图书答疑
2010-07-18
是否精华
是
否
版块置顶:
是
否
以下是form1代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace IT部门管理系统
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public TextBox textbox1 [font color=#FF0000] //此处代码是在网上找的,加上跟不不加都显示不了。[/font]
{
get { return this.textbox1; }
}
[font color=#FF0000]//textbox1的modifi属性我已按照你的方法设置为public了。[/font]
private void button1_Click(object sender, EventArgs e)
{
Form2 frm2 = new Form2();
frm2.Show();
}
}
}
//以下是form2代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace IT部门管理系统
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
Form1 frm = new Form1();
frm.textBox1.Text = "222";
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace IT部门管理系统
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public TextBox textbox1 [font color=#FF0000] //此处代码是在网上找的,加上跟不不加都显示不了。[/font]
{
get { return this.textbox1; }
}
[font color=#FF0000]//textbox1的modifi属性我已按照你的方法设置为public了。[/font]
private void button1_Click(object sender, EventArgs e)
{
Form2 frm2 = new Form2();
frm2.Show();
}
}
}
//以下是form2代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace IT部门管理系统
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
Form1 frm = new Form1();
frm.textBox1.Text = "222";
}
}
}