May i know which is the best way to update a statusbar message in MDI application.I have come across this code for displaying the message in status bar of parent form from child form but i want to update the message based on user's action. In parent form
private void Form1_Load(object sender, EventArgs e)
{
FrmShiftManagement newMDIChild = new FrmSh开发者_StackOverflow社区iftManagement();
newMDIChild.MdiParent = this;
this.LayoutMdi(MdiLayout.Cascade);
newMDIChild.Show();
StatusMessage.Text = "Ready";
//toolstriplabel1.Alignment = ToolStripItemAlignment.Right;
}
public void ShowStatus(string status)
{
this.StatusMessage.Text = status;
Application.DoEvents();
}
In Child form
((FrmTRMS)this.MdiParent).ShowStatus("Item(s) Saved");
This code is working fine when the data is saved or any action performed..Now how can i set parent form original message back to the status bar once the data is saved or deleted.
You could do this:
string oldMsg = "";
public void ShowStatus(string status)
{
oldMsg = this.StatusMessage.Text;
this.StatusMessage.Text = status;
this.StatusMessage.Invalidate(); // To force status bar redraw
this.StatusMessage.Refresh();
}
public void RestoreStatus()
{
this.StatusMessage.Text = oldMsg;
}
and use RestoreStatus()
on child form close or whenever you please.
I have got the solution w.r.to display message from child form to parent form in statusbar..I have gone through this link..http://www.codeproject.com/KB/cs/pass_data_between_forms.aspx its very helpful.
精彩评论