Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6739403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:29:06+00:00 2026-05-26T11:29:06+00:00

I have two forms named form1 and form2 : form1 is made of a

  • 0

I have two forms named form1 and form2:

  • form1 is made of a label and a button.
  • form2 is made of a textBox and a button

When I click the form1 button, this will show up form2. Any inputs in textBox should be written back to form1.label once I hit the button in form2.
I have the code below but it doesn’t work.

// Code from Form 1
public partial class Form1 : Form
{
    public void PassValue(string strValue)
    {
        label1.Text = strValue;
    }
    public Form1()
    {
        InitializeComponent();
    }
    private void button1_Click(object sender, EventArgs e)
    {
        Form2 objForm2 = new Form2();
        objForm2.Show();
    }

}

// Code From Form 2

public partial class Form2 : Form
{
    public Form2()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        Form1 objForm1 = new Form1();
        objForm1.PassValue(textBox1.Text);
        this.Close();
    }
}

And a screenshot:

Application screenshot

How can I realize that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:29:07+00:00Added an answer on May 26, 2026 at 11:29 am

    You don’t access your form1, from which you created form2. In form2 button1_Click you create new instance of Form1, which is not the same as initial. You may pass your form1 instance to form2 constructor like that:

       // Code from Form 1
     public partial class Form1 : Form
    {
        public void PassValue(string strValue)
        {
            label1.Text = strValue;
        }
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Form2 objForm2 = new Form2(this);
            objForm2.Show();
        }
    
    }
    
    // Code From Form 2
    
    public partial class Form2 : Form
    {
        Form1 ownerForm = null;
    
        public Form2(Form1 ownerForm)
        {
            InitializeComponent();
            this.ownerForm = ownerForm;
        }
    
        private void button1_Click(object sender, EventArgs e)
        {       
            this.ownerForm.PassValue(textBox1.Text);
            this.Close();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have two forms: Form1 and Form2. Form2 has a text control named
I have two forms named: Form1 & Form2 In the Form1 I have a
I have two forms named 'mainForm' and 'addRslt'. The idea is when users click
I have two forms, one with a radio button that users must select to
I have two forms. The first form is the mainForm, this never goes anywhere.
I have two forms. First one is to decide button numbers by using jslider.
I have two forms on one page and want to have the input boxes
I have two forms on my website, and I use jQuery to submit them,
I (currently) have two forms, one that needs to call the other. In other
How can two forms share the same inputs? I have two forms, one for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.