Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Form not resizable

Tags:

c#

winforms

This is sort of frustrating I have been working on an application and all of a sudden I can't resize it anymore by moving my mouse to the edge of the form. I can maximize and minimize fine with the standard buttons.

I am using FormBorderStyle = Sizable;

I have checked every property and can't seem to figure out what Property I must have accidentally changed. I can also use the Win+Left and Right to resize the form. For the life of me I can't figure out what is causing this.

Here is the code below

namespace WindowsFormsApplication1
{
    partial class Form1
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.SuspendLayout();
            // 
            // Form1
            // 
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
            this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
            this.ClientSize = new System.Drawing.Size(778, 545);
            this.Font = new System.Drawing.Font("Times New Roman", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.Margin = new System.Windows.Forms.Padding(4);
            this.Name = "Form1";
            this.Text = "Form1";
            this.ResumeLayout(false);

        }

        #endregion


    }
}
like image 353
CodeCamper Avatar asked Jun 19 '13 06:06

CodeCamper


People also ask

How do you make a form not resizable?

to make a form not resizable just change the property: FormBorderStyle to anything but not Resizable.

How do I make my windows form resizable?

To make a control resize with the form, set the Anchor to all four sides, or set Dock to Fill . It's fairly intuitive once you start using it. For example, if you have OK/Cancel buttons in the lower right of your dialog, set the Anchor property to Bottom and Right to have them drag properly on the form.

How do you make a form not resizable in VB net?

FormBorderStyle = FormBorderStyle. FixedSingle will prevent users from manually resizing the form. To prevent the form from being resized through code, handle the SizeChanged event and set the size back to the fixed size you want it to be.

How do I resize a form?

By dragging either the right edge, bottom edge, or the corner, you can resize the form. The second way you can resize the form while the designer is open, is through the properties pane. Select the form, then find the Properties pane in Visual Studio. Scroll down to size and expand it.


1 Answers

As I said in comment, here is the problem:

this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;

AutoSize should be false, and there's no need for AutoSizeMode You can find more info HERE

Note: Do not edit the question like

"I've found the answer which is: ..."

You should set it back to the version with the code.

like image 60
gkovacs90 Avatar answered Sep 28 '22 10:09

gkovacs90