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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:22:56+00:00 2026-06-09T22:22:56+00:00

I will appreciate if anyone can help me on this. I have a windows

  • 0

I will appreciate if anyone can help me on this.

I have a windows form app that has three forms: form1, form2, form3. form1 starts when the app is activated. on form1, there is a button that brings up form2, and hide form1. there is also one button that brings up form3 and hides form2 on form2.

public partial class Form1 : Form
{

    Form2 f2= new Form2();
    public Form1()
    {
        InitializeComponent();
    }
    private void button1_Click(object sender, EventArgs e)
    {
        this.Hide();            
        f2.Show();        
    }
}


public partial class Form2 : Form
{
            Form3 f3 = new Form3();
    private void button1_Click(object sender, EventArgs e)
    {
         this.Hide();
         f3.Show();                
    }
 }

The question is on form3, i tried to access some of the variables that are assigned with values on runtime in form2. I think since i make f2 as modaless form, i should be able to access by simply using f2.myvariables, but the intellisense does not give me f2 object. Why is that? I found a way to declare those variables public static, so i could access by using form2.myvariables..Here is another thing that confuses me. Since all the values are assigned during runtime, how could static variable do this? I am a newbie on C#, and i already did a lot of searches on this, but seems no place answers my question exactly. Thanks for help in advance!!

  • 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-06-09T22:22:57+00:00Added an answer on June 9, 2026 at 10:22 pm

    So you have information in the parent form (form2) that you want to access in a method of the child form (form3).

    1. Create properties in form3 for the information that it will need.
    2. When form2 creates an instance of form3 it should set those properties.

    You should think of this not as having the child form ask for information from it’s parent, but rather that the parent is giving information to its child. If you shift your mindset accordingly the code becomes not only easier to write, but also will be more in line with good coding practices (lower coupling, not exposing more information externally than needed, etc.)

    To create a property you can do something like this in form3:

    //TODO: give real name; adjust type as needed
    public string SomePropertyName { get; set; }
    

    then in form2 you can do:

    f3.SomePropertyName = "hello from form2";
    

    or

    f3.SomePropertyName = someVariableInForm2;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Anyone that can help me out will be very much appreciated. I seem to
I will really appreciate help for this. My html v2 file with some temporary
Can anyone help me with a LINQ query. I have converted most of it
Basic question.. had to ask. Any help will be appreciated. Q: Why can't I
Really hope someone can help me as I'm a bit stuck :S I have
id like to know how I can execute this. say i have an array
I'm working on an windows app. This app contains a dynamic list of names,
Just wondering if anyone can help me with a little programming math i'm having
I have an MFC project that imports a C type DLL for use. This
I'm getting myself completely confused, and would appreciate if anyone can point me in

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.