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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:01:29+00:00 2026-06-13T02:01:29+00:00

I have the following two pieces of code, please take a look at it,

  • 0

I have the following two pieces of code, please take a look at it, I pointed where it is going wrong.
I removed the functions where I call the second window, they do not make sense here.

First, main form, this form calls the second form:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace STP_Design
{
    public partial class STP2Main : Form
    {
        public STP2Main()
        {
            InitializeComponent();
            tabControl1.SelectedTab = tabPageDeviceManager;
        }
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            MenuForm MDIMF = new MenuForm();
            MDIMF.MdiParent = this;
            MDIMF.StartPosition = FormStartPosition.Manual;
            MDIMF.Location = new Point(3, 50);
            MDIMF.Show();
            tabControl1.Visible = false;
        }

        public void set()
        {
            tabControl1.Visible = true; // This statement executes, but does not result in anything I'd expect. The debugger tells me the visibility is false.
            tabControl1.BringToFront();
        }
   }
}

and second form, which I close and should update the first form:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace STP_Design
{
    public partial class MenuForm : Form
    {
        public MenuForm()
        {
            InitializeComponent();

            this.BringToFront();
        }


        private void button1_Click(object sender, EventArgs e)
        {
            STP2Main stp = new STP2Main();
            stp.set();
            this.Close();
        }
    }
}
  • 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-13T02:01:30+00:00Added an answer on June 13, 2026 at 2:01 am

    You’re calling the set method on a new version of the main form, rather than on the version you presumably already have displayed to the user.

    What you need to do is get the current main form from the MdiParent property of the menu form, and call the method on that instead.

    // In menu form
    private void button1_Click(object sender, EventArgs e)
    {
        var mainForm = this.MdiParent as STP2Main;
        if (mainForm != null)
            mainForm.set();
        this.Close();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have the following two pieces of code which i think should be identical
I have following two pieces of code First one is not explicitly disposing Image
In two different views I have the following two pieces of code. FIRST <table
I have the following two pieces of code: public class C { public void
I have the following two chunks of code, I am not so sure what
Let's say I have the following two pieces of XML in my database <!--
I have the following piece of code. See the two comments for the problem.
I have these two pieces of code that each return a relation inside the
I have these two pieces of code that could possibly be run at the
I ran the following two pieces of code on Windows XP (Code:Block, MinGW), and

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.