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 7039533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:48:36+00:00 2026-05-28T01:48:36+00:00

I am trying to return some data from Form2 to Form1, everything seems fine,

  • 0

I am trying to return some data from Form2 to Form1, everything seems fine, I got the data and so, but, when I try to pass my data to a textbox, it doesn’t changes the text. Only if I open a new instance of Form1, on Form2 it works. Why this happen? Can’t I send the text to the old instance?

I’m using this code;

Form1 (Main Form)

public void updateText(string data)
{
    MessageBox.Show(data);
    txtGood.Text = data;
}

Form2 SecondaryForm = new Form2();

SecondaryForm.ShowDialog();

Form2 (Second Form with user data)

Form1 MainForm = new Form1();
MainForm.updateText(data);
MainForm.ShowDialog();
this.Close();

So, my question is, how can I pass the data values to the old instance of the main form? without having to create a new instance and show a new instance. Is there a way to do this?

  • 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-28T01:48:36+00:00Added an answer on May 28, 2026 at 1:48 am

    What you can do is pass the reference of MainForm(Form1) to second Form(Form2). Then instead of creating MainForm again use the reference to update the textbox.

       //pass reference to form2
       Form2 SecondaryForm = new Form2(mainForm);
       SecondaryForm.ShowDialog();
    
        //in the constructor of Form2 save the reference of Form1
        Form1 form1 = null
    
        Form2(Form1 mainForm)
        {
            form1 = mainForm;
        }
    
        //then instead of creating a new MainForm again just use reference of Form1
    
        form1.updateText(data);
        this.Close()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to create a list to return some JSON data to a view. Following
I'm trying to return a string from a function. Which basically adds some chars
I am trying to write some code to return an array in C#, but
I am trying to read some data from html forms and insert it into
I am trying to display some data from text file with an array. The
im trying to return a string value from a method inside my script tag
Im trying to return the value that a $ajax call returns, from a function
I'm trying to return a dictionary from a function. I believe the function is
I'm trying to return a transparent GIF from an .aspx page for display within
i'm trying to send some radio buttons from a form with ajax, the problem

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.