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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:16:50+00:00 2026-05-26T13:16:50+00:00

I have 2 Windows Forms. In first, the main window form, has multiline textbox

  • 0

I have 2 Windows Forms.

In first, the main window form, has multiline textbox and a button. The button opens the second form in which I can add data to array by using AddEntry object.

In second form I have textboxes and a button (btnAddEntry) which should update the content of the textbox from first form.

When data is entered I want to display data in textbox from the first form.

The problem is that code I came up with doesn’t seem to work.

How would I solve 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-26T13:16:51+00:00Added an answer on May 26, 2026 at 1:16 pm

    To get the BASICs working, do the following.. Create a new project. Nothing of your current code, windows, etc… The default project will create a form “Form1” leave it alone for now.

    Add a NEW form to the project, it will default to “Form2″… Put a single textbox on it and a single button on it. For grins, and clarification to differentiate between the object names, change the name of the controls on Form2 to “txtOnForm2”, and “btnOnForm2” (case sensitive for my sample, and readability vs “txtonform2” all lower case). Now, on the form, right-click and click “View Code”. It will bring you to the other “Partial class” declaration where your constructors are found. Add the following, dont worry about compile errors as the other half will be when we put code into Form1 next…

    // specifically typecasting the TYPE of form being passed in, 
    // not just a generic form.  We need to see the exposed elements
    Form1 CalledFrom;
    // Ensure to do the : this() to make sure default behavior
    // to initialize the controls on the form are created too.
    public Form2(Form1 viaParameter) : this()
    {
      CalledFrom = viaParameter;
    }
    
    private void btnOnForm2_Click(object sender, EventArgs e)
    {
      CalledFrom.ValuesByProperty = this.txtOnForm2.Text;
      MessageBox.Show( "Check form 1 textbox" );
    
      string GettingBack = CalledFrom.ValuesByProperty;
      MessageBox.Show( GettingBack );
    
      CalledFrom.SetViaMethod( "forced value, not from textbox" );
      MessageBox.Show( "Check form 1 textbox" );
    
      GettingBack = CalledFrom.GetViaMethod();
      MessageBox.Show( GettingBack );
    }
    

    Save and close the Form2 designer and code window.

    Now, open Form1. Put a single textbox and a single button on it. The default names for the controls will be “textbox1” and “button1” respectively. Leave it as is. Double click on the button (on form1). It will bring up a snippet for code for that button. Paste the following

    private void button1_Click(object sender, EventArgs e)
    {
       Form2 oFrm = new Form2(this);
       oFrm.Show();
    }
    
    public string ValuesByProperty
    {
      get { return this.textBox1.Text; }
      set { this.textBox1.Text = value; }
    }
    
    public void SetViaMethod(string newValue)
    { this.textBox1.Text = newValue; }
    
    public string GetViaMethod()
    { return this.textBox1.Text; }
    

    Now, save the forms and run them. Click button on first form, calls the second with the already created instance of itself, not a new SECOND instance of itself. The second form will be displayed. Shift the windows so you can see both.

    Enter some text in the textbox second window and click the button… follow the back/forth of what is coming/going.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple windows application in C# with 3 forms. first form is
I'm using Windows Forms in C#. I have a main form with a couple
I have a Windows Forms (.NET) application that can have multiple documents open simultaneously.
I have a Windows Forms app, that has a single ElementHost containing a WPF
I have a windows forms app with a textbox control that I want to
I have an app with a TPageControl on the main form. The pagecontrol has
I have a windows form application which needs to be the TopMost. I've set
I have a main form (MainForm) and a MDI child window (TFormChild). I want
I have a window form that has a couple of combo boxes. What I
I have windows forms application wich runs another console application here is the part

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.