我有一個MainForm和AnotherForm。 AnotherForm通過MainForm的menuItem訪問。如何將值從一種形式傳遞給另一種?
AnotherForm有listView。當用戶點擊一個項目時,我想獲取字符串元素並將其傳遞給MainForm的文本框,因此該元素在那裏顯示並且AnotherForm已關閉。到目前爲止,AnotherForm關閉,但沒有在MainForm的文本框中顯示。有什麼建議麼?
private void listView1_ItemActivate(object sender, EventArgs e)
{
string input = listView1.SelectedItem[0].ToString();
MainForm mainF = new MainForm(input);// called the constructor
this.Close(); //close this form and pass the input to MainForm
mainF.inputTextBox.Text = input;
mainF.loadThis(input);
}