将子窗体中的选项卡合并到主窗体中

发布于 2024-08-03 05:19:30 字数 132 浏览 4 评论 0原文

我在主窗体中有页面控件,在子窗体中有页面控件,我 使用停靠功能将子窗体放置在主窗体内。

我没有使用 MDI 样式

现在两个表单在页面控制中都有选项卡,我需要合并子表单 将选项卡插入主窗体页面控件,最好的方法是什么?

I have page control in main form and page controls in child form , I
place the child form inside the main form by using docking features.

I am not using MDI style

Now both forms have tabs in page control and I need to merge the child form
tabs into the main form page control, what is the best way to do that?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

祁梦 2024-08-10 05:19:30

处理页面控件上的多个选项卡的最简单、最好的方法通常是使用框架。获取每个选项卡的内容并将它们分解到每个选项卡的单独框架中。将所有共享组件、状态和代码移至数据模块。然后只需将这些框架放置在页面控件的选项卡上即可。

The simplest and best way to handle multiple tabs on a page control is usually with Frames. Take the contents of each tab and factor them out into an individual frame for each tab. Move any shared components, state and code to a data module. Then just place those frames on the tab sheets of your page control.

暖树树初阳… 2024-08-10 05:19:30

这是一种相当简单的方法,可能适合也可能不适合您的需求。

对于需要合并的每个子选项卡页面:

  • 在主表单页面中创建一个选项卡
    对应子控件
    tab

  • 迭代控件
    子选项卡并更改父级
    属性到您刚刚的标签页
    创建

您不需要处理其他控件的子控件。例如,如果您的子选项卡中有一个组框,则更改其父级会将其及其中的所有控件带到新的父级。

如果您需要能够随时“取消合并”选项卡,那么您将需要设计一些机制来跟踪控件的来源,以便您可以在需要时恢复原始的父级

为了让事情变得更简单,您可以在子选项卡中放置一个TPanel,并将其Align属性设置为alClient。将选项卡中的所有控件放置在该面板上,然后当您需要合并/取消合并时,只需设置面板控件的父级

This is a fairly simple approach that may or may not suit your needs.

For each child tab page you need to merge:

  • Create a tab in the main form page
    control corresponding to the child
    tab

  • Iterate over the Controls in the
    child tab and change the Parent
    property to the tab page you just
    created

You do not need to deal with controls that are children of other controls. e.g. if you have a groupbox in your child tab, then changing it's parent will bring both it and all controls within it to the new parent.

If you need to be able to "unmerge" your tabs at any point then you will need to devise some mechanism to keep track of where the controls came from so you can restore the original Parent as/when needed.

To make things slightly easier you could place a TPanel in the child tabs, with it's Align property set to alClient. Place all the controls in the tab on that panel and then when you need to merge/unmerge you need only set the Parent of the panel control.

北方。的韩爷 2024-08-10 05:19:30

我刚刚尝试过

procedure TForm1.Button1Click(Sender: TObject);
begin
  while Form2.PageControl1.PageCount > 0 do
    Form2.PageControl1.Pages[0].PageControl := PageControl1;
end;

,效果很好。我是否遗漏了一些明显的东西,或者为什么每个人都给出如此复杂的解决方案? :-)

I just tried

procedure TForm1.Button1Click(Sender: TObject);
begin
  while Form2.PageControl1.PageCount > 0 do
    Form2.PageControl1.Pages[0].PageControl := PageControl1;
end;

and it worked fine. Am I missing something obvious, or why is everybody giving such sophisticated solutions? :-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文