C# – MDI window list not updating child title bar texts

cmdimenuwinforms

I have a MDI container form, and some child forms that update their title bar texts themselves, independently. After the Text property is changed on the child form, the new title bar text from the child is not updated in the window list menu when the menu is opened. This is the auto-generated window list provided by .NET via the MdiWindowListItem property.

The change only propagates when another event changes the window list physically (opening a new child, closing a child, switching to another child).

Is there a way to force an update of the window list programmatically? I already have some code in place to do menu enabling/disabling at the same time the child's title bar text is changed.

I tried the following with no success:

  • Update() on the main MenuStrip
  • Refresh() on the main MenuStrip
  • Invalidate() on the window MenuStrip
  • Invalidate() on one of the window list items at runtime
  • Toggling the Checked state twice on one of the window list items at runtime

There don't seem to be any other remotely viable functions to call on the menu item, its parent ToolStrip, or the parent form that contains the menu system.

Best Answer

The above solution did not work for me. But I followed the link, and found this, which works perfectly:

private void windowMenu_DropDownOpening(object sender, EventArgs e)
{
    if (this.ActiveMdiChild != null)
    {
        Form activeChild = this.ActiveMdiChild;

        ActivateMdiChild(null);
        ActivateMdiChild(activeChild);
    }
}

Thank you!

Related Topic