Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All..

How can I change my MDIParent "StatusStrip" when I am in a MdiChild FORM ? I have to change toolStripStatusLabel.text from MdiChild form.
I did some ways.. But not working that...
I used
C#
MDI frm =new MDI(txtStatusBarMessage.Text);
child form and public constructor in MDI form
C#
public MDI(string StatusbarText)
       {
           ToolStripStatusLabel ToolStripStatusLabel = new ToolStripStatusLabel();
           StatusStrip statusStrip = new StatusStrip();
           this.toolStripStatusLabel.Text = objMasterData.GetStatusBarMessage();
           statusStrip.Items.Add(ToolStripStatusLabel);
           this.Refresh();
       }

in another way
C#
public MDI(string StatusbarText)
       {
      this.toolStripStatusLabel.Text = objMasterData.GetStatusBarMessage();--> this make an exception "Object reference not set to an instance of an object.".
      }


And also i did adding public property for toolStripStatusLabel.Text.but not working that..
please help me...

Thanks in advance...

Vineetha.K.R
Posted
Updated 5-Jan-13 1:02am
v2

1 solution

it's quite simple just set status trip from MDI-Child form
C#
Name of MDI form.toolStripStatusLabel = txtStatusBarMessage.Text;

or
C#
((Name of MDI form)(this.MdiParent)).toolStripStatusLabel.Text =  txtStatusBarMessage.Text;


you need not to use constructor or any public method inside MDI form

Happy Coding!
:)
 
Share this answer
 
v3
Comments
Vineetha Ravindranath 5-Jan-13 7:28am    
Thank You for Your response.
I used ((MDI)(this.MdiParent)).toolStripStatusLabel.Text = txtStatusBarMessage.Text;
Still make an exception Arti..
Aarti Meswania 5-Jan-13 7:29am    
what is the name of your MDI form?
Vineetha Ravindranath 6-Jan-13 23:14pm    
It's MDI.
Aarti Meswania 6-Jan-13 23:41pm    
open your mdi form's designer.cs page
now, at bottom of page, you will see declarations of controls
private System.Windows.Forms.ToolStripMenuItem toolStripStatusLabel;
set it public instead of private
public System.Windows.Forms.ToolStripMenuItem toolStripStatusLabel;

now, build project (Note : it should be successful build)
now, you can access that control of mdi in child form
Vineetha Ravindranath 7-Jan-13 1:02am    
I Changed Modifier of toolStripStatusLabel as public. so it changed
as public System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel;Then I used the code MDI frm =new MDI ();
frm.toolStripStatusLabel.Text = txtStatusBarMessage.Text;
frm.Refresh(); now have no exception.But no chandes in statusbar.
from loading status bar shows Ready for operation.then i have to change the text from it's child form.but this code not changing the text.
I used the code ((MDI)(this.MdiParent)).toolStripStatusLabel.Text; here MdiParent become null. so exception occured.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900