带有固定的右侧静态面板

带有固定的右侧静态面板

本文介绍了高度可变的FlowLayoutPanel,带有固定的右侧静态面板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好好看一下

我有一个 Top Panel ,该面板停靠在表单的Top(AutoSize == TrueAutoSizeMode == GrowOnly)上.在其中,我有一个 FlowLayoutPanel 停靠在Fill(AutoSize == TrueAutoSizeMode == GrowOnly),一个普通的 Static Panel 停靠在Right(). 静态面板具有固定的宽度,但是其高度可以拉伸. FlowLayoutPanel 包含许多向右对齐的子元素.

I've got a Top Panel which is docked to the Top of my form (AutoSize == True, AutoSizeMode == GrowOnly). Inside of that I have a FlowLayoutPanel docked to Fill (AutoSize == True, AutoSizeMode == GrowOnly), and a plain Static Panel docked to the Right (AutoSize == False). The Static Panel has a fixed width, but its height can be stretched. The FlowLayoutPanel contains a number of child elements that align to the right.

我想要这样,当用户将表单的大小调整为所有FlowLayout子级不能适合与 FlowLayoutPanel 顶部面板相同的行"时和静态面板的高度都增加了,以使被截断的孩子适合第二条线",也可能是第三条,第四条,依此类推.

I want it so when the user resizes the form to where all of the FlowLayout children can't fit on the same "line" that the FlowLayoutPanel, Top Panel and Static Panel all grow in height to fit the cut off children on a second "line", and possibly third, fourth and so on.

就目前的情况而言(在此示例中),可能重叠的孩子被撞到第二条线",但是没有一个高度可以拉伸以显示它们.我在各种面板中以各种方式摆弄了各种停靠和自动调整大小的参数.

As it stands (in this example), the would-be overlapped children get knocked to the second "line" but none of the heights stretch to show them. I've fiddled in all sorts of ways with various docking and autosize parameters in these various panels.

我认为这并不太困难,但仅使用设计时可用的功能就无法使其工作.也许这是不可能的,或者我错过了一些东西.谢谢你!

I figured this wouldn't be too difficult but I can't get it to work using just the features available in design time. Maybe It's not possible or I'm missing something. Thank ya!

推荐答案

我尝试了多种方法.这是对我有用的东西:

I tried multiple things. Here is what worked for me:

TableLayoutPanel(Anchor= Top, Left, RightColumnCount=2 RowCount=1Autosize = TrueAutosizeMode = GrowAndShrink)替换顶部面板,并为Right Column设置x像素的固定宽度(Left Column将调整为100 %)

Replace your Top Panel with a TableLayoutPanel(Anchor= Top, Left, Right, ColumnCount=2 RowCount=1, Autosize = True, AutosizeMode = GrowAndShrink) and give the Right Column a fixed Width of x pixel(Left Column will adjust to 100%)

在左列中输入FlowLayoutPanel(Autosize = TrueAutosizeMode = GrowAndShrinkAnchor= Top, Left, Right)

在右列中放入Panel(Autosize = FalseAnchor= Top, Bottom, Left, Right)

外观如下:蓝色= FlowLayoutPanel,绿色= Panel

Here is what it look:Blue= FlowLayoutPanel, Green=Panel

调整大小之前
调整大小后

Before Resize
After Resize

请不要忘记为表单设置最小宽度.或者看起来像这样

Don't forget to set a min Width to your form. Or it could look like this

这篇关于高度可变的FlowLayoutPanel,带有固定的右侧静态面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 16:12