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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:16:43+00:00 2026-06-04T21:16:43+00:00

I readed manu articles about this, but – still confused. from Form1 I open

  • 0

I readed manu articles about this, but – still confused.

from Form1 I open Form2:

new Form2().Show();

On Form2.ClosingEvent I need:

Form1.TextBox1.Visible = false;

What code and exactly where should I put – to achieve 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-06-04T21:16:44+00:00Added an answer on June 4, 2026 at 9:16 pm

    The problem is that, the way your code is currently structured, your instance of the Form2 class knows nothing about your instance of the Form1 class. Therefore, it cannot access properties or call methods on the other object. Remember that Form1 and Form2 are the names of classes, not objects.

    The hacky solution would be to add a public field to your Form2 class that holds a reference to your Form1 object. You would fill in that field after you create an instance of your Form2 class, but before you call the Show method.

    The next problem you’ll run into is that, by default, controls on a form are private, which means that only code inside of the class that defines the form can access them. They cannot be accessed or manipulated from code inside of a different class.

    The design you have is fundamentally broken from an object-oriented perspective. One class should not be manipulating or accessing private members of another class.

    If anything, you should be handling this all in Form1. Modify the Form2 class to raise an event when it gets closed, and then subscribe to that event from Form1. Inside of the Form1 event handler method, hide the textbox.

    The quick and dirty solution would be to switch to the ShowDialog method, which shows another form and blocks execution until that form gets closed. Then you could write:

    // Create an instance of your Form2 class and show it as a modal dialog
    using (var f = new Form2())
    {
        f.ShowDialog(this);
    }
    
    // When the ShowDialog method returns, the Form2 form has closed, so
    // you can go ahead and change the visible state of your control on Form1.
    this.TextBox1.Visible = false;
    

    However, the disadvantage of modality is that the user cannot interact with Form1 while Form2 is open. It’s not clear from your question whether or not that is workable. If not, I recommend the previous solution, which involves raising an event. Either way, I highly recommend that you pick up a book on object-oriented programming in C#. Design like this is hard to fix later if you get it wrong.

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

Sidebar

Related Questions

I readed the userguide also this question , but still have problem with the
I have readed something about it i wanna to do some implementation using this.
First of all, I have already readed this: Validating form dropdown in CodeIgniter But
i have readed many topic but i'm pretty confused. it seems that: if ([[UIScreen
I readed this: Drop Pin on Default Google Maps from My App in Android?
i have readed many topics but i'm very confused. i don't know if use
this is my first question, but I've readed StackOverflow for years. Well the thing
Readed about 30 minutes, and didn't found some specific for this in this site.
I readed some tutorials about making droplets with apple script or with automator's help.
First, is Google+ project open source? I readed some time ago that google+ is

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.