我有一个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);
}