Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

How to reference a control on a parent form from a child form

$
0
0

In a parent form, I am trying to change the text on a statusbar panel from an event in a child form, but I don't know how to reference the statusbar control on the parent.  I tried the following, but the control value for sbSB is null.

StatusBar sbSB = (StatusBar)this.Parent.Controls["sbStatusBar"];
sbSB.Panels[0].Text = "Active Form = Equipment Types";

I also tried the following, but the text did not get updated:

(this.Parent.Controls["sbStatusBar"] as StatusBar).Panels[0].Text = "Active Form = Equipment Types";

My goal is to update the statusbar text on the parent form to display the name of the form with focus.

Experience trumps brilliance -- Thomas Sowell



Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>