這是get user input in form 2 and display data in form 1的主題連接。setter c#顯示錯誤請確保您沒有無限循環或無限遞歸
這是我在form2中的代碼。
public string UserText
{
get
{
return this.textBox1.Text;
}
set
{
this.UserText = value;
}
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
MessageBox.Show("Please enter keyword to search");
}
else
{
//anta data input to form1.
UserText = textBox1.Text;
}
,這是我在Form1
private void Form1_Load(object sender, EventArgs e)
{
Form2 form2 = new Form2();
form2.ShowDialog();
string text = form2.UserText;
}
代碼,我想,當我們點擊按鈕的搜索,當我們加載Form1上會自動顯示數據。
當我運行,它說,在二傳手:
確保你沒有一個無限循環或無限遞歸。
爲什麼這麼說?我做錯了什麼?
我也試過了。
public string UserText
{
get
{
return this.UserText;
}
set
{
this.UserText = value;
}
}
但它看起來是一樣的。
==== ====編輯現在 我試着這樣做:
public string UserText
{
get
{
return this.textBox1.Text;
}
set
{
this.textBox1.Text = value;
}
}
也是我想這:
public string UserText { get; set;}
它並不顯示錯誤然而,它也不加載form1。操作就停在那裏。有什麼我做錯了嗎?
它與我上面的評論相同。它不顯示錯誤,但爲什麼當我點擊button1時,它不會出現form1?我應該添加什麼來使它加載form1呢? – 2012-08-07 02:25:18