Click here to Skip to main content
Click here to Skip to main content

Access Parent Statusbar from a child

, 30 Nov 2004 CPOL
Rate this:
Please Sign up or sign in to vote.
Update the parent's status bar panel(s) from a child MDI form

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)

Share

About the Author

LimeyRedneck
Technical Lead Synovus
United States United States
A conforming non-conformist (yes they exist), currently employed as a Technical Analyst and solution architect in the financial sector.
 
I am addicted to the Atlanta Braves, my two boys and my wife in various orders based on the circumstances and context.

Comments and Discussions

 
GeneralMy vote of 5 Pinmemberginojmg27-Nov-11 2:16 
GeneralThanks Pinmemberpintamono29-Dec-08 8:02 
Generalthe simplest way to access the status bar of the mdi parent PinmemberSalman Farooq13-Mar-08 3:01 
GeneralRe: the simplest way to access the status bar of the mdi parent PinmemberLimeyRedneck15-Mar-08 9:10 
GeneralRe: the simplest way to access the status bar of the mdi parent PinmemberMember 397851720-Mar-08 19:28 
Questionhow can we set MDI.Parent of relevant form as nothing Pinmembermshariq14-Nov-07 2:01 
AnswerRe: how can we set MDI.Parent of relevant form as nothing PinmemberLimeyRedneck28-Nov-07 14:52 
GeneralRe: how can we set MDI.Parent of relevant form as nothing Pinmembermshariq28-Nov-07 19:54 
QuestionWhat to do? Pinmembertomek13m14-May-07 3:24 
AnswerRe: What to do? PinmemberLimeyRedneck14-May-07 17:58 
GeneralThanks PinmemberDrPete23-Apr-07 23:39 
GeneralRe: Thanks PinmemberLimeyRedneck24-Apr-07 7:42 
GeneralSmartly Done Pinmemberdavelalit16-Sep-06 0:37 
GeneralWell done!!! PinmemberNikola Knezevic18-Aug-06 0:33 
GeneralThank You much Pinmembermarek.pastorek23-May-06 1:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141223.1 | Last Updated 30 Nov 2004
Article Copyright 2004 by LimeyRedneck
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid