为“面板中的控件”设置锚点在“flowlayoutpanel”内

发布于 2024-11-01 04:16:59 字数 255 浏览 5 评论 0原文

在我的Windows应用程序中,

我在flowlayoutpanel中有一个普通面板在

这个普通面板中,我有一些输入控件(例如标签,文本框...)

我已经设置了锚点属性,认为当我调整窗口大小时它会自动调整大小。

但是当我测试它时,只有 flowlayoutpanel 自动调整大小,因为我可以看到滚动条已进一步向右移动......普通面板中的控件根本没有移动。

有人知道这里出了什么问题吗?

谢谢你!

In my windows application

I have a normal panel inside a flowlayoutpanel

In this normal panel, i have some input controls(e.g. labels, textbox...)

I have set the anchor properties thinking that it will auto-resize when I resize the window.

But when i tested it, only the flowlayoutpanel auto-resize itself, as i can see that the sroll bar has moved further toward the right... the contorls in the normal panel didnt move at all.

anyone know what is wrong here?

Thank You!

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

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

发布评论

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

评论(2

七月上 2024-11-08 04:16:59

我也遇到过同样的问题。显然,FlowLayoutPanel 中的控件的大小是根据该面板中最宽的控件来调整的。我通过覆盖 FlowLayoutPanel 上的“Resize”事件并更改相对于 FlowLayoutPanel 大小的控件之一来解决此问题:

private void RulesPanel_Resize(object sender, EventArgs e)
{
    FlowLayoutPanel panel = (FlowLayoutPanel)sender;
    button_in_panel.Width = panel.Width - 50;
}

设置一个控件后,其他控件的大小就会正确调整。对于那些指定了锚点的情况也是如此。

I have encountered the same problem. Apparently, the controls in the FlowLayoutPanel are sized according to the widest control in this panel. I've solved this by overriding the 'Resize' event on the FlowLayoutPanel and change one of the controls relative to the size of the FlowLayoutPanel:

private void RulesPanel_Resize(object sender, EventArgs e)
{
    FlowLayoutPanel panel = (FlowLayoutPanel)sender;
    button_in_panel.Width = panel.Width - 50;
}

Once one is set, the others are resized properly. This is also true for those that have Anchors specified.

魄砕の薆 2024-11-08 04:16:59

在下面的帖子中,莱尼已经回答了这个问题

cannnot-resize-child-controls -in-a-flowlayoutpanel-control

或这个:

flowlayoutpanel-issues

所以我认为没有办法。
您究竟为何需要这种控制?

In the following post Lenny answered the question already

cannnot-resize-child-controls-in-a-flowlayoutpanel-control

or this:

flowlayoutpanel-issues

So i think theres no way.
For what exactley you need that control?

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