在不同表单之间更改字符串 [英] Change a string between different forms

查看:81
本文介绍了在不同表单之间更改字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在不同表单之间更改ID字段。在下面的示例中,我展示了如何,现在我的问题是如何添加第二个字段ID2更改表单?



MAIN FORM LINK BUTTON:



I change the ID fields with between different forms. In the example I below shows how, Now my question is how can I add a second field ID2 change the forms?

MAIN FORM LINK BUTTON:

privete void BUTTON_Click(object sender, EventArgs e)
{
this.Cursor = Cursors.WaitCursor;
            Form1 Form = new Form1(XX_ID.Text); //also add xx_ID2.text
            Form.Show();
            this.Cursor = Cursors.Default;
}





Form1接收数据并将其粘贴到标签中;



Form1 receives the data and paste it into a label;

public Form1 (string ID)//receive also the ID2
{
InitializeComponent();

LB_XXID.text = ID;
//LB_XXID2.text = ID2;
}





我尝试了什么:



msdn.microsoft。 COM;但是没找到正确的文章



What I have tried:

msdn.microsoft.com; But have not found the right article

推荐答案

创建第二个表单构造函数,或者改变第一个:

Create a second form constructor, or alter the first:
public Form1 (string ID, string ID2)
{
InitializeComponent();
 
LB_XXID.text = ID;
LB_XXID2.text = ID2;
}


使用参数数组



Use array of parameters

public Form1 (string[] idValues = null)
{ }





像这样传递





Pass in like this

string[] idValues = new string[] { "ID1", "ID2" };
// Replace "ID1" and "ID2" with whatever actual values you need to use.
Form1 form1 = new Form1(idValues);


这篇关于在不同表单之间更改字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆