我有一个 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:
似乎没有任何其他远程可行的函数可以在菜单项、其父 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 窗口列表不更新子标题栏文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!