pass a value from one form to another

后端 未结 7 1171
Happy的楠姐
Happy的楠姐 2020-11-27 21:10

I have two forms, and I need pass a value from form1.textbox1 to form2.variable

Form1:

string Ed = \"\", En = \"\"; 

public string En1
{
    get { r         


        
相关标签:
7条回答
  • 2020-11-27 22:07

    You can create constuctor for form2 which accept 2 arguments and access these variables

    Form2 frm2 = new Form2(textBox1.Text,textBox2.Text);
    frm2.Show(); 
    

    Constructor would look like

    public Form2(string txt1,string txt2)
        {
            InitializeComponent();
            textbox1value.Text = txt1;
            textbox1value.Text=txt2
    
        }
    

    There are many ways to pass data between forms such as

       1) Using constructor
       2) Using objects
       3) Using properties
       4) Using delegates
    

    Check this link for details http://www.codeproject.com/Articles/14122/Passing-Data-Between-Forms

    Hope It helps!

    0 讨论(0)
提交回复
热议问题