Delphi 中的流体表单布局

发布于 2024-08-12 06:51:14 字数 361 浏览 9 评论 0原文

我们开发了一个软件。在此软件中,我们根据不同的情况在不同的输入屏幕上显示和隐藏一些控件。

当我们隐藏一个控件时,会发生的情况是该控件占用的空间保持原样,并且布局有时看起来非常糟糕,特别是。在具有大量控件的屏幕中。我们的客户不喜欢这样,并要求我们对此采取措施。

我的问题: 是否有某种方法可以创建流体布局,以便当隐藏控件时,其余控件会自动调整自己以填充隐藏控件留下的空白空间,并且当显示控件时,它们应该自动为控件让路并相应地调整自己。

我知道我们可以通过编码来实现这一点,但这需要在每个屏幕中使用大量代码来调整布局。我正在寻找可以减少每个屏幕编码的东西,因为有 80 多个屏幕。

请建议一些更容易出错并且可以消除每个输入屏幕中不必要的编码的方法。

We have developed a software. In this software we are show and hiding a few controls on various input screens depending on various situations.

When we hid a control what happens is that the space occupied by that control is left as it is and layout looks very bad at times esp. in screens that have larger numbers of controls. Our client does not like this and has asked us to do something about this.

My question:
Is there some way by which we can create Fluid Layouts so that when a control is hidden the rest of the controls automatically adjusts themselves to fill the empty space left by the control hidden and when the control is show they should automatically make way for the control and adjust themselves accordingly.

I know we can achieve this by coding but that will require a lot of code in each screen for adjusting the layout. I am looking something which will reduce coding in each screen as there are 80+ screens.

Please suggest some way which is less error pron and can get rid of unnecessary coding in each input screen.

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

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

发布评论

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

评论(5

盗梦空间 2024-08-19 06:51:14

我认为最好的选择是使用一个组件来处理运行时表单上 vcl 控件的布局(取决于您定义的条件)。我建议您尝试 Devexpress ExpressLayout Control

您可以在这里找到两个很棒的演示视频

替代文字
(来源:devexpress.com

您可以检查这些功能

自动管理< /strong> - 控件组和单个控件元素由布局控件自动管理。您永远不必担心逐像素定位。

表单自动调整大小 - 表单可以自动调整大小以最适合其内容。

再见。

I think your best option is to use a component that handles the layout of your vcl controls on your form in runtime (depending on the conditions that you define). I recommend you try the Devexpress ExpressLayout Control

you can find two great demo videos here

alt text
(source: devexpress.com)

You can check these features

Auto-Management - Control groups and individual control elements are automatically managed by the Layout Control. You never worry about pixel-by-pixel positioning.

Form auto-sizing - The form can be automatically resized to fit its contents best.

Bye.

维持三分热 2024-08-19 06:51:14

现在,我不确定您的布局有多复杂,但我想您可以使用 TFlowPanel 和/或 TGridPanel 来实现此目的。 Flowpanel 对改变可见性的组件有很好的处理能力。我不确定 gridpanel 处理同样的事情效果如何......

Now, I'm not sure how complex layout you have, but I guess you can use TFlowPanel and/or TGridPanel for this. Flowpanel has a nice handling of components that change visiblity. I'm not sure how well gridpanel handles the same...

小忆控 2024-08-19 06:51:14

您动态隐藏哪种控件,自动填充空间是什么意思?

我不知道是不是这么简单:将控件放在面板上,然后使用对齐alTop/alClient/alBottom。当您隐藏某个面板时,所有其他面板将自动向上移动。
但有一个问题:如果你想再次显示一个面板,面板的顺序有时可能会被搞乱......可以通过手动设置 .Top 属性来修复,或通过设置 .Height := 1; 来“隐藏”;

What kind of controls are you dynamically hiding, and what do you mean with auto fill space?

I do not know if it is as this simple: place controls on panels, and use align alTop/alClient/alBottom. When you hide a panel, all other panels will move automatically up.
One problem though: if you want to show a panel again, the order of panels can sometimes be screwed up... Can be fixed by manually setting .Top property, or "hide" by setting .Height := 1;

最冷一天 2024-08-19 06:51:14

我对复杂布局所做的实际上是将其分成几个选项卡。这有两个优点。它简化了表单布局,并允许您根据其他选项卡中的选择显示和隐藏整个选项卡。

What I would do with a complex layout is actually split it up into several tabs. This has two advantages. It simplifies the form layout, and allows you to show and hide whole tabs depending on choices made in other tabs.

内心旳酸楚 2024-08-19 06:51:14

Raize 组件 有一个 TRzFlowPanel UI 组件。正是您所追求的。

使用 TRzFlowPanel 在表单上放置一个空的流程面板。传统面板和流程面板之间的主要区别在于控件的放置方式。使用传统面板,您可以将控件(例如按钮)放置在特定位置。您可以使用鼠标将该控件自由移动到面板内的任何位置。在流程面板中,每个控件都放置在特定位置,无论您使用鼠标将其放置在何处。自动位置由 FlowStyle 属性控制。例如,使用 LeftRightTopBottom 的默认 FlowStyle 属性,添加到流程面板的第一个控件将捕捉到左上角。您添加的第二个控件将捕捉到第一个控件旁边,依此类推。

Raize Components have a TRzFlowPanel UI component. Does exactly what you're after.

Use TRzFlowPanel to put an empty flow panel on a form. The major difference between a traditional panel and a flow panel is the way in which controls are placed. With a traditional panel, you place a control (such as a button) in a specific location. You can freely move that control to any location within the panel using the mouse. In a flow panel, each control is placed in a specific location, regardless of where you place it with the mouse. The automatic location is controlled by the FlowStyle property. For example, using the default FlowStyle property of LeftRightTopBottom, the first control you add to the flow panel snaps to the top left corner. The second control that you add snaps next to the first control, and so on.

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