MDI 窗口列表不更新子标题栏文本

MDI window list not updating child title bar texts(MDI 窗口列表不更新子标题栏文本)
本文介绍了MDI 窗口列表不更新子标题栏文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我有一个 MDI 容器表单,以及一些独立更新其标题栏文本的子表单.在子窗体上更改 Text 属性后,当打开菜单时,子窗体中的新标题栏文本不会在窗口列表菜单中更新.这是 .NET 通过 MdiWindowListItem 属性提供的自动生成的窗口列表.

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:

  • 主 MenuStrip 上的 Update()
  • Refresh() 在主 MenuStrip 上
  • Invalidate() 在窗口 MenuStrip 上
  • 在运行时对窗口列表项之一进行 Invalidate()
  • 在运行时在窗口列表项之一上切换 Checked 状态两次

似乎没有任何其他远程可行的函数可以在菜单项、其父 ToolStrip 或包含菜单系统的父窗体上调用.

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.

推荐答案

上述解决方案对我不起作用.但我按照链接,发现了这个,效果很好:

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);
    }
}

谢谢!

这篇关于MDI 窗口列表不更新子标题栏文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

ActiveDirectory error 0x8000500c when traversing properties(遍历属性时 ActiveDirectory 错误 0x8000500c)
search by samaccountname with wildcards(使用通配符按 samaccountname 搜索)
Get the list of Groups for the given UserPrincipal(获取给定 UserPrincipal 的组列表)
Can you find an Active Directory User#39;s Primary Group in C#?(你能在 C# 中找到 Active Directory 用户的主要组吗?)
Query From LDAP for User Groups(从 LDAP 查询用户组)
How can I get DOMAINUSER from an AD DirectoryEntry?(如何从 AD DirectoryEntry 获取 DOMAINUSER?)