2013-02-17 275 views
0

我有兩種形式,都帶有一個文本框,當輸入字符串時,富文本框顯示它。我希望能夠創建一個類或一些參考,我可以在其中定義一個變量'text'並將其設置爲與輸入'textBox1.Text'相等。當用戶在文本框中輸入任何內容時,我想將其作爲變量存儲,並將其顯示在另一個屏幕上。如果能夠做到這一點,你能告訴我,它真的令人沮喪!通過變量全局訪問控制

回答

0

聽起來Passing data between two instantiated WinForms in C#

但在你的情況下,只需要創建一個static class讓的說

public class static Setter 
{ 
    //Properties 
    public static string set1{ get; set; } 
    public static string set2 { get; set; } 
} 

然後你就可以像使用

string test = "test"; 
Setter.set1 = test;