我有一个 FlowLayoutPanel,上面有多个控件。我只想在垂直方向滚动。但是当我设置时AutoScroll = true
,我得到了垂直和水平滚动条。如何禁用水平滚动条而只保持垂直滚动条工作?
问问题
28213 次
3 回答
63
- 将自动滚动设置为 true
- 将WrapContents设置为 false。
- 确保大小大于控件的宽度加上垂直滚动条的宽度。
水平滚动条应该消失。如果没有,请提供更多信息。
于 2011-04-05T18:27:35.837 回答
5
将自动滚动设置为真。将 WrapContents 设置为 false。将右边距设置为 10。
这对我来说工作得很好。
于 2016-03-25T13:04:47.360 回答
-1
以下是我如何在 FlowLayoutPanel 上使用换行文本(WrapContents = true),仅垂直滚动条来实现多个标签。
- 我在表单上有一个 flowLayoutPanel1
- 设置 form 和 flowLayoutPanel1 的属性,如下所示:
形式:
AutoScroll = True
FormBorderStyle = Sizable(default)
流布局面板1:
Anchor = Top, Left, Right
AutoSize = True
FlowDirection = TopDown
WrapContents = true
- 在表单类上实现此代码以进行测试
int coorY = 0;
public Form2()
{
InitializeComponent();
for (int i = 0; i < 100; i++)
{
flowLayoutPanel1.Controls.Add(new Label
{
Location = new Point(0, coorY + 20),
Font = new Font("Segoe UI", 10f),
Text = "I have a FlowLayoutPanel and there are multiple controls on it. I only want to scroll in vertical",
Width = flowLayoutPanel1.Width,
AutoSize = true
});
coorY += 20;
}
}
于 2021-06-01T03:57:31.133 回答