5,545,925 members and growing! (16,378 online)
Email Password   helpLost your password?
Languages » C# » Windows Forms     Intermediate License: The Code Project Open License (CPOL)

Access Parent Statusbar from a child

By LimeyRedneck

Update the parent's status bar panel(s) from a child MDI form
C#, VC7.1, C++, .NET, Windows, WinXP, MFC, VS.NET2003, Visual Studio, Dev

Posted: 30 Nov 2004
Updated: 30 Nov 2004
Views: 23,190
Bookmarked: 11 times
Announcements
Want a new Job?



Search    
Advanced Search
Sitemap
8 votes for this Article.
Popularity: 3.18 Rating: 3.52 out of 5
2 votes, 25.0%
1
1 vote, 12.5%
2
0 votes, 0.0%
3
1 vote, 12.5%
4
4 votes, 50.0%
5

Introduction

Like many others I have been searching for a way to access the statusbar on a MDI parent form from a child in the simplest and least code intensive manner.

Again, like most others I have found that this appears to be like the Holy Grail .... someone knows but is not telling.

Well after wasting my time on searches and finding all kinds of advice on reflection, events etc I decided to do some coding - hacking in the old sense.

The following code works quite nicely, but has only been tested on an XP Pro system using VSNet2K3.

Steps to do

Assuming a status bar with 1 panel ....

  • In the child form add the following variable:
    public System.Windows.Forms.StatusBarPanel pfrm_sbp1 = null;
  • Add the following code where you want to update the statusbar PANEL:
    pfrm_sp1.Text = "How did he do that?";
  • In the parent form when you create the child, set the reference:
    Form2 newMDIChild = new Form2();
    newMDIChild.MdiParent = this;
    newMDIChild.pfrm_sp1 = statusBarPanel1;
    newMDIChild.Show();

Of course, you could do this via other more secure mechanisms (please do) - make the reference variable private with get/set functions, perhaps make it an array of panel references, but you get the basic idea now don't you.

Anything more pervasive would benefit from a more comprehensive and better design here's an excellent article (link) to guide you if you decide to go further down into the internals of inter window communications.


License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

LimeyRedneck


A conforming non-conformist (yes they exist), I do contract work as a Technical Analyst and solution architect. Currently mentoring my local High School Robotics team in Programming and Web design.

I am addicted to the Atlanta Braves, my two boys and my wife, in various orders based on the circumstances and context.

Occupation: Web Developer
Location: United States United States

Other popular C# articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 13 of 13 (Total in Forum: 13) (Refresh)FirstPrevNext
Subject  Author Date 
Generalthe simplest way to access the status bar of the mdi parentmemberSalman Farooq3:01 13 Mar '08  
GeneralRe: the simplest way to access the status bar of the mdi parentmemberLimeyRedneck9:10 15 Mar '08  
GeneralRe: the simplest way to access the status bar of the mdi parentmemberMember 397851719:28 20 Mar '08  
Questionhow can we set MDI.Parent of relevant form as nothingmembermshariq2:01 14 Nov '07  
AnswerRe: how can we set MDI.Parent of relevant form as nothingmemberLimeyRedneck14:52 28 Nov '07  
GeneralRe: how can we set MDI.Parent of relevant form as nothingmembermshariq19:54 28 Nov '07  
GeneralWhat to do?membertomek13m3:24 14 May '07  
GeneralRe: What to do?memberLimeyRedneck17:58 14 May '07  
GeneralThanksmemberDrPete23:39 23 Apr '07  
GeneralRe: ThanksmemberLimeyRedneck7:42 24 Apr '07  
GeneralSmartly Donememberdavelalit0:37 16 Sep '06  
GeneralWell done!!!memberNikola Knezevic0:33 18 Aug '06  
GeneralThank You muchmembermarek.pastorek1:03 23 May '06  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 30 Nov 2004
Editor: Nishant Sivakumar
Copyright 2004 by LimeyRedneck
Everything else Copyright © CodeProject, 1999-2008
Web19 | Advertise on the Code Project