【发布时间】:2014-01-03 08:32:06
【问题描述】:
我想要 2 个表单,其中第一个表单有一个按钮,可以在对话框表单中加载 form2。 form2 将显示一个显示学生数据的列表视图。现在我需要提取所选行的第一个索引。一旦我双击该行,form2 将关闭并将数据传递到 form1 中的文本框。
我使用下面的代码关闭了我的 form1 并在 form2 中创建了一个新的 form1 实例。
来自form2:
private void listView1_DoubleClick(object sender, EventArgs e)
{
var cl = listView1.Items[listView1.FocusedItem.Index].SubItems[0].Text;
Form1 wa= new Form1();
wa.loadid(cl);
wa.Show();
this.Close();
}
来自表格1:
private void btnReq_Click(object sender, EventArgs e)
{
Form2 f2= new Form2();
f2.Show();
this.Close();
}
public void loadid(String ms)
{
String newstring = ms;
studentid.Text = newstring;
}
【问题讨论】: