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

  • Home
  • SEARCH
  • 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 6719851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:08:30+00:00 2026-05-26T09:08:30+00:00

form A opens form B, and form A.visible = false; form A has a

  • 0

form A opens form B, and form A.visible = false;

form A has a public int variable and I need controls in form B to be able to access and modify this variable. could this be done as passing the value through the constructor is only one way!

and so if it could be done, if form A is not visible could the value still be accessed?

(form b is not supposed to be dialog!)

many thanks!

edited: I do not quite get the explanations actually. so far it is like that:

in form a:

    //in global space
    public int temp = 123;

    //in form_load event
    Form setup = new setup();
    setup.Show();
    this.Visible = false;

in form setup:

    //in form_load event
    textBox1.text = temp.toString();

    //in button_press event
    form a.temp = "456";

I hope I have explained my stance clearly!

  • 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-26T09:08:31+00:00Added an answer on May 26, 2026 at 9:08 am

    First, have member field in form B of type form A:

    private FormA parent;
    

    Second, have such constructor in form B:

    public FormB(FormA parent)
        : this()
    {
        this.parent = parent;
    }
    

    Now when you create instance of form B, pass reference to the running form A instance:

    FormB formB = new FormB(this);
    formB.Show();
    

    And you can access the public property through the parent field e.g.

    //inside Form B code..
    public Foo()
    {
        parent.PUblicProp = "Hello";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form with 2 tab controls. Form opens on tab 1. I
To recreate this behaviour, you need to create a pop-up form with the following
When starting up Word from a form in Access, I do this: Dim wordApp
I have a form that opens at startup (frmStart). That form has some code
I am coding a program where a form opens for a certain period of
How to change the first record to be displayed when a Windows Form opens?
My application is based on modal forms. Main form opens one form with ShowModal,
I have created a tab control and few forms. Each form opens in a
C# / .NET 3.5 / WinForms I've got a form that opens a modal
I know that a submit button in HTML can submit a form which opens

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.