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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:56:16+00:00 2026-06-01T06:56:16+00:00

In my current application I have a main form: frmMain with a statusstrip and

  • 0

In my current application I have a main form: frmMain with a statusstrip and a label: lblStatus inside that.
I would like to update that label from inside my user controls, which I add to my main form when I click the concerning button:

ucBeheer ucBeheer = new ucBeheer();
splitContainer1.Panel2.Controls.Add(ucBeheer);

From inside my usercontrol when I do an action, I would like to update lblStatus. I have tried adding the following property to my main form:

    public string updateStatus
    {
        get { return lblStatus.Text; }
        set { lblStatus.Text = value; }
    }

And then accessing the method like this in my user control:

        frmMain mainForm = new frmMain();
        mainForm.updateStatus = "This is a test";

But that doesn’t work, I know that this is because I am making a new object of my frmMain, but I don’t know how to solve this otherwise?

I have also found the following way, with an Event Handler but I can’t do that because my user control isn’t actually in my mainForm yet, until I add it there with clicking on the button, so I don’t have a reference to it.

So I’m kinda out of ideas, I hope somebody can help me.
Thanks,
Thomas

Edit: So I managed to do it the following way:

        frmMain owningForm = (frmMain)this.Parent.Parent.Parent.Parent;
        owningForm.updateStatus = "This is a test";

but this.Parent.Parent.Parent.Parent... doesn’t really seem like good coding to me, is there any other way to get the most top parent?

  • 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-01T06:56:17+00:00Added an answer on June 1, 2026 at 6:56 am

    You could add a property like this to your usercontrol, with this you can access the frmMain that the usercontrol resides in.

    public frmMain MainForm
    {
        get
        {
            var parent = Parent;
            while (parent != null && (parent as frmMain) == null)
            {
                parent = parent.Parent;
            }
            return parent as frmMain;
        }
    } 
    

    UPDATE:
    If you just want the top most parent you could use something like this:

    public Control TopMostParent
    {
        get
        {
            var parent = Parent;
            while (parent.Parent != null)
            {
                parent = parent.Parent;
            }
            return parent;
        }
    } 
    

    Or even make an extension method of that:

    public static Control TopMostParent(this Control control)
    {
        var parent = control.Parent;
        while (parent.Parent != null)
        {
            parent = parent.Parent;
        }
        return parent;
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that is good from September 1st of the current year,
I have an application that has a UILabel displaying the current date and time,
I have an web application that displays employee birthdays for the current month in
i have created an application which show data from user current location. I want
I would like to create application with ribbon interface that looks and behaves like
We have a web application that is based around a form that gets passed
Let's say you have a form with a component that displays data from a
Here's my code so far. I have the main form and wcf objects that
Windows Forms, .net 2.0 My main application thread has a form (A). I have
Suppose, I have the following task. There is a main application form with numerous

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.