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

孤人 提交于 2019-12-02 07:13:07

问题


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


回答1:


Use the Height property. For instance:

this.Height = newHeight;



回答2:


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;
        }    



回答3:


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



来源:https://stackoverflow.com/questions/12682506/how-do-i-resize-a-windows-forms-form-in-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!