[英]How can I pass a list from form1 to form2 to access it in a ButtonEvent in form2?
[英]How can I retrive other values of form 1 when returning data from form2?
代码form1
,
Picklist f2 = new Picklist(Query, this.Text);
f2.Show();
form2
,
DataGridViewRow Row = dgvPicklist.Rows[index];
this.Hide();
ItemMaster f2 = new ItemMaster(Row);
f2.Show();
好的,要将值从form1发送到form2:
在form1中:
form2 F = new form2(something); // something is the value you need to send
F.show();
在form2中:
public form2(string x) //Considering the type of your value is string, you can replace that with the required data type.
{
string something = x; //sets the value of x to something. Just like it was in form1.
InitializeComponent();
}
我已经考虑过要作为string
传输的值的数据类型。
您可以根据需要进行更改。
使用ShowModal()
代替Show()
:
Picklist f2 = new Picklist(Query, this.Text);
f2.ShowModal();
string valueFromForm1 = TextBox1.Text;
ShowModal()
等待打开的窗体关闭,然后执行其余代码
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.