有两个窗体Form1、Form2,Form2继承Form1,在Form2 中如何对父窗口Form1中的变量重新赋值。能不能重新赋值呀?
解决方案 »
- C++ 回调C#函数的问题
- Win7下使用Jumplist的Resent或者自定义分组一定要注册文件类型吗?
- 急,关于DataGridViewComboBoxColumn数据的绑定
- 不是可识别的表提示选项。如果它要作为表值函数的参数,请确保您的数据库兼容模式设置为90
- C#用来做什么?
- 读入图象问题
- 大家快帮帮忙啊
- 50分,请高手给一些在windows2003系统下用.net开发构架voip服务端和客户端的资料
- Main()里定义了 public属性,其他窗口如何引用
- C#如何获取Access数据库中字段的数据类型
- 如何停止正则表达式匹配
- C#文件传输,客户端下载的文件怎么都是BMP格式??请问是哪里的问题,我想传.dat文件
public string FormText = "Test";
private void Form1_Load(object sender, EventArgs e)
{
this.Text = FormText;
}
我想在子窗口,form2中对FormText重新赋值,form2中该怎么写呀?
private Form2 frm; public Form1()
{
InitializeComponent();
this.Text = FormText;
}
private void button1_Click(object sender, EventArgs e)
{
frm = new Form2();
frm.button1.Click += new EventHandler(ChangeValue);
frm.Show();
} void ChangeValue(object sender, EventArgs e)
{
this.FormText = frm.textBox1.Text;
this.Text = this.FormText;
}Form2中:
public TextBox textBox1;
private static string a; //定义一个静态变量
public string aa
{
get { return a; } //返回a
set { a = value; } //a可以被修改,假如不需被修改,则不用写set
}a可以在其他地方随便改Form2的 Form1 a = new Form1();
string str = a.aa; //已经获取到Form1得a了刚刚写的,应该没问题。
{
public Form2()
{
this.Load += new EventHandler(Form2_Load);
} void Form2_Load(object sender, EventArgs e)
{
this.Text = "abcd";
}
}