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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:42:19+00:00 2026-06-14T06:42:19+00:00

I was not able to locate an answer on stackoverflow so here it goes.

  • 0

I was not able to locate an answer on stackoverflow so here it goes. I am attempting to change the text of a MenuStrip subitem when clicking a button on a sub form. Below is the code from my Submit button on my sub form. when clicked it should change the text of “Log In” to “Log Out”. Code seems fine and no errors but does not update the text.

public AccessForm()
{
    InitializeComponent();
}

private void btnSubmit_Click(object sender, EventArgs e)
{
    try
    {
        if (txtUser.Text == "admin" && txtPass.Text == "1234")
        {
            MessageBox.Show("Access granted.", "Access");

            playgroundPlannersForm mainForm = new playgroundPlannersForm();

            mainForm.logInToolStripMenuItem.Text = "Log Out";
            this.Close();

        }
        else
        {
            MessageBox.Show("Incorrect Username or Password.", "Warning");
            txtUser.Clear();
            txtPass.Clear();
            txtUser.Focus();
        }
    }
    catch (Exception ex)
    {
        MessageBox.Show("Message: " + ex, "Error");
    }
}

private void btnCancel_Click(object sender, EventArgs e)
{
    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-14T06:42:20+00:00Added an answer on June 14, 2026 at 6:42 am

    You’re creating a new instance of the main form and changing that; you need to be passing along the reference to the original form and using that to update it.

    Here’s one way to do it. In your sub form.. add this property:

    public playgroundPlannersForm ParentForm { get; set; }
    

    ..then, in your code above, use this:

    MessageBox.Show("Access granted.", "Access");
    
    //playgroundPlannersForm mainForm = new playgroundPlannersForm(); <--- not needed anymore
    
    ParentForm.logInToolStripMenuItem.Text = "Log Out";
    

    In your main form, before you show your subform.. do this:

    SubForm subform = new SubForm();
    subform.ParentForm = this;
    subform.Show();
    

    That sets the parent to the form that’s creating it (which, according to your code, is the correct form). You may also need to go into your form designer code and make the loginToolStripMenuItem public (if it isn’t already).

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

Sidebar

Related Questions

I have not been able to locate the answer using Google search. I know
I am not able to apply onclick event in global custom text field. This
I'm not able to locate the repeater controller called 'repScore' which is located inside
There seems to be another process loading the cache, but not able to locate
I am not able to locate a particular header file on disk, while my
am developing one dictionary for mac os 10.6. Am not able to locate glib.h.
Not able to download artifacts from central maven repository. <mirrors> <!-- mirror | Specifies
Not able to store all binary data values into sqlite3 table using QT. For
not able to get this, can someone help for this LINQ query? select col1,
Im not able to load the page with circlepageindicator. This is the xml <FrameLayout

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.