J
John J. Hughes II
I have an MDI application and would like to display messages to the status
bar of he parent window. I am really not happy about putting a status bar
on every MDI window and would prefer it to only be on the main window.
I have written the below function but think there must be a better way, is
there?
public static void WriteStatusBar(Form frm, string msg)
{
try
{
if(frm != null && frm.Parent != null && frm.Parent.Parent != null)
{
foreach(object c in frm.Parent.Parent.Controls)
{
if(c.GetType().ToString().EndsWith("StatusBar"))
{
StatusBar sb = (StatusBar)c;
sb.Panels[0].Text = msg;
break;
}
}
}
}
catch(Exception stEx)
{ System.Diagnostics.Debug.WriteLine(stEx.Message); }
}
Regards,
John
bar of he parent window. I am really not happy about putting a status bar
on every MDI window and would prefer it to only be on the main window.
I have written the below function but think there must be a better way, is
there?
public static void WriteStatusBar(Form frm, string msg)
{
try
{
if(frm != null && frm.Parent != null && frm.Parent.Parent != null)
{
foreach(object c in frm.Parent.Parent.Controls)
{
if(c.GetType().ToString().EndsWith("StatusBar"))
{
StatusBar sb = (StatusBar)c;
sb.Panels[0].Text = msg;
break;
}
}
}
}
catch(Exception stEx)
{ System.Diagnostics.Debug.WriteLine(stEx.Message); }
}
Regards,
John