javed khan
how to transfer text from a textbox of one form to another forms textbox?
By javed khan in Windows Forms on Apr 08 2009
  • Rajanikant Hawaldar
    Oct, 2022 13

    use properties, delegate and events

    • 0
  • Neeraj Srivastava
    Apr, 2009 12

    Consider Form1 contains a textbox named textBox1 and a button named button1
    Form2 contains no controls .

     When user clicks on button1 textBox1's text    will be transfered from form1 to form2 by writing this code.

    Code for Form1 :

    private void button1_Click(object sender, EventArgs e)

    {

    this.Hide();

    Form2 f2 = new Form2();

    TextBox text=new TextBox ();

    f2.Controls.Add(text);

    text.Text = textBox1.Text;

    f2.Show();

    }


     

    • 0
  • Padmashree Shettigar
    Apr, 2009 9

    Consider Form1 contains a textbox named textbox1 and a button named button1
    Form2 contains a textbox named textbox1. When user clicks on button1 text will be transfered from form1 to form2 by writing this code.

    We are passing the reference of form1 to form2.

    Code for Form1 :

    private void button1_Click()
    {
    Form2 obj=new Form2(this);
    obj.show();
    }


    Code for Form2:


    Form1 obj;
    public Form1(Form1 obj1)
    {
     obj=obj1;
     InitializeComponent();
    }

    private void Form2_Load(object sender, EventArgs e)
    {
    textbox1.Text=obj.textbox1.Text;
    }

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS