在 .NET 中创建新的最大化 MDI 子窗体时出现图标问题
我有一个 .NET 3.5 MDI WinForms 应用程序。
我设置了子表单的 Icon
属性,并且图标正确显示在表单的左上角。 然后我最大化子窗体,图标仍然可以。
在子窗体仍然最大化的情况下,我打开另一个子窗口,它会自动最大化。 此窗体的图标不是 Icon
属性中的图标,而是默认的 .NET 图标(带有蓝色、红色和黄色方块的图标)。 但是,如果我调整 MDI 父窗体的大小,图标会自行重置并正确显示。
有谁有解决方法或知道为什么会发生这种情况?
I have a .NET 3.5 MDI WinForms application.
I set a a child form's Icon
property, and the icon shows up correctly in the top left corner of the form. I then maximize the child form and the icon is still OK.
With the child form still maximized, I open another child window, which automatically comes up maximized. This form's icon is not the one in the Icon
property, but the default .NET icon (the one with the blue, red, and yellow squares). However, if I resize the MDI parent form, the icon resets itself and displays properly.
Does anyone have a workaround or know why this happens?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
对 Calanus 解决方案的轻微修改:
这允许您在设计时设置图标(就像对其他表单一样),并且不需要任何硬编码文件或资源访问。
A slight modification to Calanus' solution:
This allows you to set the icon at design time (just as you would for other forms), and does not need any hard-coded file or resource accessing.
是的,我找到了解决方案...
解决方法是在子窗体的加载事件上再次设置图标,如下所示:
这确实意味着您必须首先将有问题的图标文件添加到您的 VS 项目/解决方案并将其设置为“始终复制”,以便在构建解决方案时复制该解决方案。
华泰
哲水蚤属
Right I have found a solution...
The workaround for this is to set the icon again on the load event of the child form as follows:
This does mean that you will have to first add the icon file in question into your VS project/solution and set it to "Copy Always" so that is copied when your solution is built.
HTH
Calanus
我发现唯一的解决方案是停用然后重新激活 MDI 子项:
这是 MSDN 论坛上的回复 对我有用。
I found that the only solution was to deactivate and then reactivate the MDI child:
This is the solution given in this reply on MSDN forums and it worked for me.
我发现这也可以解决问题。
I found out this will fix the problem as well.
将其添加为 MDI 子项的 Form_Load 方法中的第一行对我有用:
Adding this as the first line in the Form_Load method on the MDI Children works for me:
我的解决方案:
将 MdiChild“ShowIcon”属性设置为 true,指定一个 1x1 透明图标。 问题解决了。
My solution:
Leave the MdiChild "ShowIcon" property set to true, assign a 1x1 transparent icon. Problem solved.
解决了我的问题!
Solved my problem!
我发现解决此问题的最佳解决方法是
处理程序
The best workaround that I found to fix this issue is here.
the handler