Just in case anyone else struggles with this, I failed miserably to get the
window list managed for me automatically. In the end, I added a
DropDownOpening event handler in my MDI form load event:
MainMenu.MdiWindowListItem.DropDownOpening += new
EventHandler(this.UpdateWindowMenuList);
This causes the UpdateWindowMenuList method to run when I select the menu
assigned to contain the window list:
private void UpdateWindowMenuList(object sender, EventArgs e)
{
// The code to update the window list on the Window menu does not
appear
// to work - so I've cobbled this together.
Application.DoEvents();
foreach (ToolStripItem tsMenu in
MainMenu.MdiWindowListItem.DropDown.Items)
{
if (tsMenu is ToolStripMenuItem)
{
ToolStripMenuItem tsMenuItem = (ToolStripMenuItem)tsMenu;
if (tsMenuItem.IsMdiWindowListEntry)
{
// Work out the index of this form.
int iIndex = Int32.Parse(tsMenu.Text.Substring(1, 1)) - 1;
// Update the menu
tsMenuItem.Text = String.Format("&{0} {1}", iIndex + 1,
this.MdiChildren[iIndex].Text);
}
}
}
}
In this routine, I go look for each MDI child and adjust the caption in the
WindowList menu items.
It's probably not the best solution, but it seems to be working for me.
Steve
"Steve Barnett" <no****@nodomain.com> wrote in message
news:uf**************@TK2MSFTNGP14.phx.gbl...
Sorry, not sure how this helps. It's not the caption of the parent window
that's wrong, it's the name that appears on the WindowList menu. Even
though I have a file loaded and the child window caption has been changed,
when I open the Window menu, the WindowList shows the "original" caption
that the child window had before I changed it.
Steve
"Robbe Morris [C# MVP]" <in**@eggheadcafe.com> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl... There should be a .Parent or .MDIParent property on your
child form. Set its caption to your value.
myform.MDIParent.Caption = "blah"
--
Robbe Morris - 2004/2005 Microsoft MVP C#
http://www.eggheadcafe.com/forums/merit.asp
"Steve Barnett" <no****@nodomain.com> wrote in message
news:OE******************@tk2msftngp13.phx.gbl... I've created a simple MDI application and have designated the Window
menu to keep track of the mdi children. When I first load an mdi child,
it's caption consists of "File: no file loaded" and this is what appears
on the Window menu.
Now, after the mdi child loads, I call a method to load a specifically
named file. At this point, the child changes it's caption to reflect the
new file name. Unfortunately, the Window menu does not update and
remains fixed on "File: no file loaded".
Is there some trick I'm missing to ensure that the Window menu gets
updated to reflect the new child window caption?
Incidentally, I've found that this problem does not happen in the
development environment, but always happens on the compiled application.
Opening a second child window usually sorts the problem out.
I've tried invalidating the Window menu item and tried refreshing the
MenuStrip, but without any success.
Thanks
Steve