5

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


    }
}
CodeCamper
  • 6,609
  • 6
  • 44
  • 94
  • Did you set a fixed width/height? – bash.d Jun 19 '13 at 07:00
  • @bash.d I don't think so, he said he could use maximize and minimize standard buttons. – King King Jun 19 '13 at 07:02
  • @bash.d How do you set a fixed width and height? I scanned through my code and nothing I have done seems to be related to the form itself. It appears to be something funny going on in the designer file via some property perhaps. I have no idea. – CodeCamper Jun 19 '13 at 07:04
  • 1
    To prevent guessing, post the code – Emond Jun 19 '13 at 07:06
  • Are you still using [api calls?](http://stackoverflow.com/questions/16931882/application-stuck-in-full-screen) I would check these are doing what you think they are. Also, is there a panel docked full screen or similar? it may be you can't actually reach your border due to overlapping controls – Sayse Jun 19 '13 at 07:07
  • @ErnodeWeerd exactly what I intend to say :) – King King Jun 19 '13 at 07:07
  • 2
    if `AutoSize` is true, You can not resize the form manually. Check it please –  Jun 19 '13 at 07:08
  • Put a breakpoint in your code and use the debugger to check that FormBorderStyle is still Sizable at runtime, hasn't somehow been modified. – RenniePet Jun 19 '13 at 07:09
  • @gkovacs90 really? So why can I resize my form manually (using mouse) with `AutoSize = true`? – King King Jun 19 '13 at 07:10
  • Updating Right now with code! – CodeCamper Jun 19 '13 at 07:12
  • @KingKing maybe You didn't set the `AutoSizeMode` to `GrowAndShrink`. Using it(according to MSDN):"The control cannot be resized manually." By default, You can only make the form larger. –  Jun 19 '13 at 07:13
  • @gkovacs90 that was my problem. I can make my form smaller by using the Win key shortcuts to resize the form. – CodeCamper Jun 19 '13 at 07:19
  • Wish you hadn't removed the code - the problem was a combination of factors, not just that one line. – RenniePet Jun 19 '13 at 07:22
  • RenniePet I put the code back. – CodeCamper Jun 19 '13 at 07:24
  • Almost - in the current version you've commented-out the offending lines, which defeats the purpose of saying you have a problem. But thanks. – RenniePet Jun 19 '13 at 07:26
  • RenniePet sorry fixed it! Thumb me up please so I can waste it all on a random bounty haha. I was in such a rush to fix the code I forgot. – CodeCamper Jun 19 '13 at 07:34
  • "Thumb me up please ..." - done. One other tiny point - when you direct a comment to another commenter here on SO you should write "@RenniePet", not just "RenniePet". That way the person you've directed your comment to gets a flag at the top of the SO page and is directed to go to the discussion. Otherwise he/she may never realize you've tried to direct a comment at him/her. – RenniePet Jun 19 '13 at 07:41
  • @RenniePet so this gives you an alert? I was doing it a bit in the beginning of the comments and I got lazy wasn't sure if it actually did anything. – CodeCamper Jun 19 '13 at 07:46
  • Yes, that gave me an alert. You don't need to use "@" when your comment is directed at the person who posted the question or answer your comment is under (that's why I don't have to write "@CodeCamper") but you should do it if your comment is directed at anyone else. – RenniePet Jun 19 '13 at 07:50

1 Answers1

9

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.