是否可以将一个控件锚定到另一个控件?

发布于 2024-12-01 23:18:06 字数 638 浏览 6 评论 0原文

是否可以将一个控件锚定到另一个控件?

假设我希望 Button1 与 Textbox1 控件保持 4px 距离,而无需
使用 FlowLayoutTable 控件?

“为什么会有这样的优势?” - 有人可能会问

好吧,假设您有一个带有垂直拆分器的 SplitContainer,并且您有 Textboxes
SplitContainer.Panel1 中,它们固定在左侧和右侧,但其最大尺寸
宽度小于您允许的 SplitContainer.Panel1's 宽度(也许
因为您希望文本显示在那里,或者因为额外的填充或其他什么,您可以命名它)

现在假设您在 Textbox1 旁边还有一个按钮,并且您不希望 Textbox1
Button1 重叠,因为它延伸得很远。

如果我想让我的文本框以留有空间的方式填充SplitContainer.Panel1
Button1 控件,而它们仍然锚定在右侧,我该怎么做?

Is it possible to anchor a control to another control?

Lets say i want my Button1 to keep its 4px distance from Textbox1 control without
using FlowLayoutTable control?

"Why would be this advantageous?" - one could ask

Well let's say you have a SplitContainer with a vertical splitter and you have Textboxes
in SplitContainer.Panel1 which are anchored to the left and right but their maximum size's
width is smaller than you allow to the SplitContainer.Panel1's width to have (maybe
because you want text to show up there or because additional padding or whatever,you name it)

Now let's say you also have a button next to Textbox1 and you dont want Textbox1 to be
overlapped by the Button1 because its extends to far.

If i want to have my textbox fill the SplitContainer.Panel1 in a fashion that it leaves space for
Button1 control while still both of them are anchored to the right how would i do it?

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

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

发布评论

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

评论(2

熟人话多 2024-12-08 23:18:06

我广泛使用 TableLayoutPanels 和 FlowLayoutPanels 来完成此任务。对于您的具体情况,我将使用一个 TableLayoutPanel,每个文本框包含三列和一行。

第 1 列:自动宽度,包含所有带有 AutoSize = True 的标签。
第 2 列:100% 宽度,包含全部带有 Anchor = Left, Right 的文本框。
第 3 列:自动宽度,包含相应行中的按钮。

接下来,我设置除按钮旁边的 ColumnSpan = 2 之外的所有文本框。然后只需将TableLayoutPanel放入SplitPanel中并设置Dock = Fill即可。

I extensively use TableLayoutPanels and FlowLayoutPanels to accomplish this. For you specific circumstance I would use a TableLayoutPanel with three columns and a row for each TextBox.

Column 1: Auto-width, contains Labels all with AutoSize = True.
Column 2: 100% width, contains TextBoxes all with Anchor = Left, Right.
Column 3: Auto-width, contains the Button in the appropriate row.

Next, I set all text boxes, except for the one next to the button, ColumnSpan = 2. Then just put the TableLayoutPanel in the SplitPanel and set Dock = Fill.

莫多说 2024-12-08 23:18:06

这将是现场的一个序列,应该从左侧流出并继续工作,让右侧应该进行布局。

  1. 应提供清单项目安全注意事项。
  2. 应提供并检查在此方法中使用的所有事物的列表项;

it will be a sequence in live which should be flow out from left and keep working lets the right side should be layout.

  1. List item safty cares should be provided.
  2. List item all things that use in this method should be provided and be check;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文