【发布时间】:2011-04-05 18:21:53
【问题描述】:
我有一个 FlowLayoutPanel,上面有多个控件。我只想在垂直方向滚动。但是当我设置AutoScroll = true 时,我得到了垂直和水平滚动条。如何禁用水平滚动条而只保持垂直滚动条工作?
【问题讨论】:
标签: c# winforms scrollbar flowlayoutpanel
我有一个 FlowLayoutPanel,上面有多个控件。我只想在垂直方向滚动。但是当我设置AutoScroll = true 时,我得到了垂直和水平滚动条。如何禁用水平滚动条而只保持垂直滚动条工作?
【问题讨论】:
标签: c# winforms scrollbar flowlayoutpanel
水平滚动条应该消失。如果没有,请提供更多信息。
【讨论】:
将 AutoScroll 设置为 true。 将 WrapContents 设置为 false。 将 Padding Right 设置为 10。
这对我来说很好用。
【讨论】:
这是我如何在 FlowLayoutPanel 上使用换行文本(WrapContents = true),仅垂直滚动条来实现多个标签。
表格:
AutoScroll = True
FormBorderStyle = Sizable(default)
flowLayoutPanel1:
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;
}
}
【讨论】: