How do I resize a Windows Forms form in C#?

前端 未结 3 1008
野趣味
野趣味 2021-01-19 06:36

I am making a Windows Forms application. I want the forms height to increase after a button is pressed. How do I do this?

相关标签:
3条回答
  • 2021-01-19 06:53

    You can just increase the form height value by a specified amount on the button click:

    private void button1_Click(object sender, EventArgs e)
    {
        int amountToIncrease = 10;
        this.Height += amountToIncrease;
    }    
    
    0 讨论(0)
  • 2021-01-19 07:00
    this.Size = new Size(175, 125);
    

    or

    this.ClientSize = new Size(175, 125);
    

    From MSDN: The size of the client area of the form is the size of the form excluding the borders and the title bar.

    http://msdn.microsoft.com/en-us/library/9278sfx2(v=vs.80).aspx

    0 讨论(0)
  • 2021-01-19 07:08

    Use the Height property. For instance:

    this.Height = newHeight;
    
    0 讨论(0)
提交回复
热议问题