MDI 窗口列表不更新子标题栏文本
- 作者: 凹加凸等于啥
- 来源: 51数据库
- 2022-10-20
问题描述
我有一个 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);
}
}
谢谢!
- C#通过fleck实现wss协议的WebSocket多人Web实时聊天(附源码)
- 团队城市未满足要求:MSBuildTools12.0_x86_Path 存在
- 使用 MSBuild.exe 在发布模式下构建 C# 解决方案
- 当我发布 Web 应用程序时,AfterPublish 脚本不运行
- 构建时 T4 转换的产品仅在下一个构建中使用
- ASP.NET Core Application (.NET Framework) for Windows x64 only error in project.assets.json
- 新的 .csproj 格式 - 如何将整个目录指定为“链接文件"到子目录?
- 如何将条件编译符号(DefineConstants)传递给 msbuild
- MSBuild 支持 Visual Studio 2017 RTM 中的 T4 模板
- NuGet 包还原找不到包,没有源
