WinForms 中的 Dock 布局问题 +开发快运

发布于 2024-11-05 13:40:21 字数 988 浏览 5 评论 0原文

我有一个 WinForms 对话框,上面有很多 DevExpress 元素。 该表单有几个 SplitContainers 和一个 TextEdit 元素以及 DevExpress XtraGrid 控件。

所有控件都是 Dock=Fill,或者对于工具栏,Dock=Top。

当我调整表单大小时,它不会重新布局所有元素,结果如下: http:// /dl.dropbox.com/u/51344/winforms1.png

直到我手动调整其中一个 SplitContainer 的大小,表单重新布局和一切都恢复正常( http ://dl.dropbox.com/u/51344/winforms2.png)。

我尝试调用在表单的 OnResize 事件中找到的所有“PerformLayout、Refresh、Redraw”函数,但没有成功。

在 RemoteDesktop 中运行时,该问题会导致更严重的布局问题。

有谁知道如何调试这个问题?


编辑:

我讨厌回答我自己的问题,几天来断断续续地与这个问题作斗争。 这段丑陋的代码似乎可以解决问题。将 splitcontainer 的大小调整一个像素以强制重新布局:

splitContainerControlQuery1.SplitterPosition += (splitContainerControlQuery1.SplitterPosition % 2 == 1) ? 1 : -1;

splitContainerControlQuery2.SplitterPosition += (splitContainerControlQuery2.SplitterPosition % 2 == 1) ? 1 : -1;

I have a WinForms dialog with a lot of DevExpress elements on it.
The form has few SplitContainers and a TextEdit element and DevExpress XtraGrid controls.

All of the controls are Dock=Fill or, in the case of the toolbars, Dock=Top.

When I resize the form it doesn't relayout all the elements, with these results: http://dl.dropbox.com/u/51344/winforms1.png.

It's not until I resize one of the SplitContainers manually that the form relayouts and everything is ok again ( http://dl.dropbox.com/u/51344/winforms2.png ).

I've tried to invoke all of the "PerformLayout, Refresh, Redraw" function I could find in the OnResize event of the form with no luck.

The problem results in even worse layout issues when running in RemoteDesktop.

Does anyone have an idea how to debug this issue?


Edit:

I hate to answer my own question, been battling with this on and off for few days.
This ugly piece of code seems to do the trick. Resize the splitcontainers by one pixel to force a re-layout:

splitContainerControlQuery1.SplitterPosition += (splitContainerControlQuery1.SplitterPosition % 2 == 1) ? 1 : -1;

splitContainerControlQuery2.SplitterPosition += (splitContainerControlQuery2.SplitterPosition % 2 == 1) ? 1 : -1;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文