MDI window list does not update title text lines

I have an MDI container form and some child forms that update their headers on their own. After changing the Text property on a 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 an auto-generated window list provided by .NET through the MdiWindowListItem property.

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

Is there a way to force the window list to refresh? I already have some code to enable / disable the menu at the same time the title bar text changes.

I have tried the following with no success:

  • Refresh () on the main MenuStrip
  • Refresh () on the main MenuStrip
  • Invalidate () on Window MenuStrip
  • Invalidate () for one of the window list items at runtime
  • Switching check state twice to one of the window list items at runtime

There doesn't seem to be any other remotely viable function to call a menu item, its parent ToolStrip, or a parent form that contains a menu system.

+2


source to share


3 answers


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

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

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



Thank!

+7


source


You need to add TextChanged event to child form using this handler:

private void childForm_TextChanged(object sender, EventArgs e) {
    this.ActivateMdiChild( null );
    this.ActivateMdiChild( sender as Form );
} 

      



http://social.msdn.microsoft.com/forums/en-US/winforms/thread/a36b89aa-57aa-48b5-87a6-49fbddc9c92d

+2


source


Instead of activating / deactivating, you can send a WM_MDIREFRESHMENU message to the MDI client window (no frame) whenever the window title has changed.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms644919%28v=VS.85%29.aspx

0


source







All Articles