如何降低控制力

Jac*_*ack 2 c# label vertical-alignment winforms

我有一个带有可变长度文本的标签,下面是一个progressBar.我想在该标签和progressBar之间保留一个空格,因此根据标签的文本(包装),应该按下progressBar,始终保持它们之间的空间.我该怎么办?我尝试了AutoSize = true,AutoSizeMode = GrowAndShrink但它没有改变任何东西.例:

 ---------------------------
|  for example the label's  |
|  text might be something  |
|  like this, with a lot of |
|  of text but the progress |
|  bar should be here       |
|                           |
| progressBar here          |
 ---------------------------
Run Code Online (Sandbox Code Playgroud)

例2:

 ---------------------------
|  small text               |
|                           |
| progressBar here          |
 ---------------------------
Run Code Online (Sandbox Code Playgroud)

Idl*_*ind 5

将Label和ProgressBar放入其属性设置为的FlowLayoutPanel中.现在,当Label垂直增长时,ProgressBar将自动下推.若要控制Label和ProgressBar之间的距离,请更改Label属性中的值.FlowDirectionTopDownBottomPadding

这是我的表单在按下按钮几次后在Form和FlowLayoutPanel(使用in )上AutoSize设置为的样子:trueGrowOnlyAutoSizeMode

在此输入图像描述

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        for(int i = 1 ; i < 20; i++)
        {
            label1.Text = label1.Text + " more ";
        }
    }
}
Run Code Online (Sandbox Code Playgroud)