C# How use sign from another window?

I have a problem with use one textBox in two Forms. I have string s = TextBox1.Text with Form1 and i need use this s on another Form2? How make it?

Hmy that public static string dont worked... I have: public void button1_Click(object sender, EventArgs e) { public static string s = textBox1.Text; } This is not worked, i need use this "s" in another metod with another window :/


将其设置为Form1上的公共静态属性,然后您可以从任何地方访问它。

//in form1
public static string s;

//in form2
TextBox.Text = Form1.s;

在Form2中有一个公共方法:SetText(String s)(或类似),它将Form1中的TextBox设置为From1。

链接地址: http://www.djcxy.com/p/51570.html

上一篇: C ++ 0x lambdas模板参数?

下一篇: C#如何使用另一个窗口的标志?