Change form size at runtime in C#

前端 未结 6 1733
傲寒
傲寒 2021-01-01 19:32

How can I change window form size at runtime?

I saw examples, but every one requires Form.Size property. This property can be set like here: http://msdn.microsoft.co

6条回答
  •  -上瘾入骨i
    2021-01-01 19:59

    If you want to manipulate the form programmatically the simplest solution is to keep a reference to it:

    static Form myForm;
    
    static void Main()
    {
        myForm = new Form();
        Application.Run(myForm);
    }
    

    You can then use that to change the size (or what ever else you want to do) at run time. Though as Arrow points out you can't set the Width and Height directly but have to set the Size property.

提交回复
热议问题