Calling Values in Usercontrol from a StatusBar on MdiParent

  • Thread starter Thread starter JDude
  • Start date Start date
J

JDude

Hi,

I am new to C#, I have been using vb6 for years. Thanks in advance for your
help.

In C# 2005, I have a MdiParent Form that has a StatusBar control with
several panels that I am trying to call the text value for. I can call the
value from a button that is directly on the mdiParent with the following code:
textbox1.text = statusBarPanel1.text;

My problem is I am trying call the value of the statusBarPanel1.text from a
usercontrol that is on the mdiParent.

Using the following code on a button on the usercontrol I can get the text
value of the statusBar by not the value of the statusBarPanel1:

this.textBox1.Text = MDIParent1.ActiveForm.Controls["statusBar1"].Text;


My goal is to get the value of each panel on the StatusBar on the mdiParent
form from a usercontrol on that same mdiParent.

If anyone can help I would be grateful.
Thanks
 
Using the following code on a button on the usercontrol I can get the text
value of the statusBar by not the value of the statusBarPanel1:

this.textBox1.Text = MDIParent1.ActiveForm.Controls["statusBar1"].Text;

There are various ways to accomplish this, but the closest to what you have
there would be to cast the control reference to a StatusBar type and then
access the properties that are status bar-specific, like its panels:

this.textBox1.Text =
((StatusBar)MDIParent1.ActiveForm.Controls["statusBar1"]).Panels[0].Text;
 
Using the following code on a button on the usercontrol I can get the text
value of the statusBar by not the value of the statusBarPanel1:

this.textBox1.Text = MDIParent1.ActiveForm.Controls["statusBar1"].Text;

There are various ways to accomplish this, but the closest to what you have
there would be to cast the control reference to a StatusBar type and then
access the properties that are status bar-specific, like its panels:

this.textBox1.Text =
((StatusBar)MDIParent1.ActiveForm.Controls["statusBar1"]).Panels[0].Text;
 
Jeff,

Thank you so much, I have been trying to figure this out for a few weeks.

JDude

Jeff Johnson said:
Using the following code on a button on the usercontrol I can get the text
value of the statusBar by not the value of the statusBarPanel1:

this.textBox1.Text = MDIParent1.ActiveForm.Controls["statusBar1"].Text;

There are various ways to accomplish this, but the closest to what you have
there would be to cast the control reference to a StatusBar type and then
access the properties that are status bar-specific, like its panels:

this.textBox1.Text =
((StatusBar)MDIParent1.ActiveForm.Controls["statusBar1"]).Panels[0].Text;
 
Jeff,

Thank you so much, I have been trying to figure this out for a few weeks.

JDude

Jeff Johnson said:
Using the following code on a button on the usercontrol I can get the text
value of the statusBar by not the value of the statusBarPanel1:

this.textBox1.Text = MDIParent1.ActiveForm.Controls["statusBar1"].Text;

There are various ways to accomplish this, but the closest to what you have
there would be to cast the control reference to a StatusBar type and then
access the properties that are status bar-specific, like its panels:

this.textBox1.Text =
((StatusBar)MDIParent1.ActiveForm.Controls["statusBar1"]).Panels[0].Text;
 
Back
Top