仅可见时,看不见的拆分重新排列的布局

发布于 2025-02-09 09:45:28 字数 786 浏览 1 评论 0原文

我想还原Windows表单的保存布局。它包含一个拆分范围,我也想恢复分离式。如果我可以看到表单时,那一切看起来都不好。因此,我试图设置splitContainer。可见为false,处理表单的设置并将可见的恢复为false。但是效果是,拆分范围内的大小在可见之前就不会更改大小,然后自动调整了分配限制,从而使其适应另一个值。在设置SplitterDistance之前更改尺寸后,PerformAutoscale()和PerformLayout()都没有帮助。如何以最佳方式解决这个问题?

  splitContainer1.Visible = false;
  FormSetMode(xxx); // sets the layout of the form
  splitContainer1.ParentForm.PerformAutoScale();
  splitContainer1.ParentForm.PerformLayout();
  splitContainer1.SplitterDistance = SplitterPosition;
  SetSplitter(fHorizontalDesigner);  // sets the splitter orientation with automatic adaption of the SplitterDistance when orientation changes
  splitContainer1.Visible = true;

如果直接与splitContainer1相关,而不是使用splitContainer1.parentform,则PerformAutoscale和Performayout不起作用。

I want to restore a saved layout of a Windows Form. It contains a SplitContainer and I would also like to restore the SplitterDistance. That all doesn't look nice if I do it while the Form is visible. Therefore I tried to set the SplitContainer.visible to false, process the settings for the form and restore visible to false. But the effect is, that the SplitContainer performs size change not before it becomes visible and then it adapts the SplitterDistance automatically to another value. Neither PerformAutoScale() nor PerformLayout() help with that after changing the size before setting the SplitterDistance. How to resolve this in best way?

  splitContainer1.Visible = false;
  FormSetMode(xxx); // sets the layout of the form
  splitContainer1.ParentForm.PerformAutoScale();
  splitContainer1.ParentForm.PerformLayout();
  splitContainer1.SplitterDistance = SplitterPosition;
  SetSplitter(fHorizontalDesigner);  // sets the splitter orientation with automatic adaption of the SplitterDistance when orientation changes
  splitContainer1.Visible = true;

PerformAutoScale and PerformLayout don't work if they are related to splitContainer1 directly instead of using splitContainer1.ParentForm.

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

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

发布评论

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