![](/img/trans.png)
[英]Add vertical scroll bar in flowLayoutPanel when control increases and horizontal automatically?
[英]How to disable horizontal scroll bar in FlowLayoutPanel?
我有一個 FlowLayoutPanel,上面有多個控件。 我只想在垂直方向滾動。 但是當我設置AutoScroll = true
,我得到了垂直和水平滾動條。 如何禁用水平滾動條而只保持垂直滾動條正常工作?
水平滾動條應該消失。 如果沒有,請提供更多信息。
將 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; } }
flowLayoutPanel1.AutoScroll = false;
flowLayoutPanel1.HorizontalScroll.Maximum = 0;
flowLayoutPanel1.VerticalScroll.Maximum = 0;
flowLayoutPanel1.AutoScroll = true;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.