Form2窗口 代码里获得字符串值, 如何传递到Form1 代码里。
以下是Form2窗口代码,获得字符串值,赋给 str字符变量,如何将该变量值,赋值给Form1窗口里。
public string str;
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
str = dataGridView1[e.ColumnIndex, e.RowIndex].Value.ToString();
this.textBox3.Text = dataGridView1[e.ColumnIndex, e.RowIndex].Value.ToString();
Close();
}
附图如下,鼠标双击表格中任何一行文字,赋值给了str, 如何传递到Form1里。
以下是Form1窗口代码。
private void Form1_Load(object sender, EventArgs e)
{
Form2 f2 = new Form2();
this.textBox1.Text = f2.str;
}
private void btnPlay_Click(object sender, EventArgs e)
{
voice.Volume = vol;
voice.Rate = Speed; ;
voice.Speak(textBox1.Text, SpeechVoiceSpeakFlags.SVSFlagsAsync);//异步朗读
}
目前这样代码,Form1里 没有获得值。
请各位检查一下,或其他方法也可以。望能详细些。谢谢!