Reputation: 104
I want to change width of a Windows Forms form at runtime. I am also executing SuspendLayout and resumelayout method, but it doesn't work.
System.Windows.Forms.Control form = this.currentForm;
form.SuspendLayout();
form.Width = form.Width + 100;
form.ResumeLayout();
How can I make it work?
Upvotes: 1
Views: 12285
Reputation: 701
Set the size of form like this
Form1.Size = new System.Drawing.Size(100, 100);
or
Form1.Size = new System.Drawing.Size(100, Form1.Size.Height);
Once the Size has been defined, you can change Form size like this
Form1.Width += 200;
Upvotes: 3
Reputation: 3469
Obviously, replace "Form1" with your form name. It's this easy:
Form1.ActiveForm.Width += 100;
Upvotes: 0