Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Windows Forms
  4. Visual Studio insists my form has changed

Visual Studio insists my form has changed

Scheduled Pinned Locked Moved Windows Forms
helpcsharpvisual-studiowinformsdesign
7 Posts 4 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    Wjousts
    wrote on last edited by
    #1

    I have an old Windows Forms project that has an annoying habit of claiming (some of) the forms have changed when they haven't. For example, I open the project. I open frmMain.cs, it appears in design mode and is immediately marked as changed (with the * next to the file name) even though I haven't do anything yet. This would be only marginally annoying except several times in the past it's managed to mess up some of the controls on the form (e.g. disappearing toolbars) when I've let it save while closing the project (without thinking about the fact that I didn't actually change anything). Has anybody else seen something like this? Has anybody else managed to fix this problem?

    R A L W 4 Replies Last reply
    0
    • W Wjousts

      I have an old Windows Forms project that has an annoying habit of claiming (some of) the forms have changed when they haven't. For example, I open the project. I open frmMain.cs, it appears in design mode and is immediately marked as changed (with the * next to the file name) even though I haven't do anything yet. This would be only marginally annoying except several times in the past it's managed to mess up some of the controls on the form (e.g. disappearing toolbars) when I've let it save while closing the project (without thinking about the fact that I didn't actually change anything). Has anybody else seen something like this? Has anybody else managed to fix this problem?

      R Offline
      R Offline
      RobCroll
      wrote on last edited by
      #2

      Someone's been writing code in the InitializeComponent method.:thumbsdown:

      #region Windows Form Designer generated code

      /// /// Required method for Designer support - do not modify
      /// the contents of this method with the code editor.
      ///
      private void InitializeComponent()
      {
      this.components = new System.ComponentModel.Container();
      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
      this.Text = "Form1";
      }

      "You get that on the big jobs."

      W 1 Reply Last reply
      0
      • W Wjousts

        I have an old Windows Forms project that has an annoying habit of claiming (some of) the forms have changed when they haven't. For example, I open the project. I open frmMain.cs, it appears in design mode and is immediately marked as changed (with the * next to the file name) even though I haven't do anything yet. This would be only marginally annoying except several times in the past it's managed to mess up some of the controls on the form (e.g. disappearing toolbars) when I've let it save while closing the project (without thinking about the fact that I didn't actually change anything). Has anybody else seen something like this? Has anybody else managed to fix this problem?

        A Offline
        A Offline
        Alan N
        wrote on last edited by
        #3

        I've seen this too and it is damned annoying! Last week I built a form from scratch and found that the problem occurred when I set the docking property of a MonthCalendar. I didn't pursue that any further as I already knew that the form.cs, .designer.cs and .resx were not changing. As for stuff disappearing I think you just have to accept that the designer will occasionally get it wrong. I've seen the error message

        Code generation for property 'Items' failed. Error was: 'An item with the same key has already been added'

        presented on a message box with a nice OK button to click. No it is not OK to remove the items from my toolstrip would be my answer but by then it's too late and usually the line of code that adds the individual items to the container has been deleted. e.g.

        toolStrip1.Items.AddRange(new ToolStripItem[]{....})

        I've got a note in the comments on one form that says "WTF - added Load event handler, toolstrip items wiped". My solution to these designer problems was an automated hourly backup of changed source code. I know that this works as the problem reoccurs only when the backup has failed! Good luck, Alan.

        1 Reply Last reply
        0
        • W Wjousts

          I have an old Windows Forms project that has an annoying habit of claiming (some of) the forms have changed when they haven't. For example, I open the project. I open frmMain.cs, it appears in design mode and is immediately marked as changed (with the * next to the file name) even though I haven't do anything yet. This would be only marginally annoying except several times in the past it's managed to mess up some of the controls on the form (e.g. disappearing toolbars) when I've let it save while closing the project (without thinking about the fact that I didn't actually change anything). Has anybody else seen something like this? Has anybody else managed to fix this problem?

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Wjousts wrote:

          Has anybody else seen something like this?

          Yup. Often in custom controls, someplace setting a property once it's shown. The Designer picks up the change, and marks the document as dirty. Checking the DesignMode[^] would be a quick work-around. If the form goes dirty, can you undo it?

          Bastard Programmer from Hell :suss:

          W 1 Reply Last reply
          0
          • W Wjousts

            I have an old Windows Forms project that has an annoying habit of claiming (some of) the forms have changed when they haven't. For example, I open the project. I open frmMain.cs, it appears in design mode and is immediately marked as changed (with the * next to the file name) even though I haven't do anything yet. This would be only marginally annoying except several times in the past it's managed to mess up some of the controls on the form (e.g. disappearing toolbars) when I've let it save while closing the project (without thinking about the fact that I didn't actually change anything). Has anybody else seen something like this? Has anybody else managed to fix this problem?

            W Offline
            W Offline
            Wjousts
            wrote on last edited by
            #5

            Thanks for all the replies. I shall check my project next time I have it open and see if any of the suggested causes might be in play for my project.

            1 Reply Last reply
            0
            • R RobCroll

              Someone's been writing code in the InitializeComponent method.:thumbsdown:

              #region Windows Form Designer generated code

              /// /// Required method for Designer support - do not modify
              /// the contents of this method with the code editor.
              ///
              private void InitializeComponent()
              {
              this.components = new System.ComponentModel.Container();
              this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
              this.Text = "Form1";
              }

              "You get that on the big jobs."

              W Offline
              W Offline
              Wjousts
              wrote on last edited by
              #6

              I don't *think* I changed anything in there, but I'll make sure to double check.

              1 Reply Last reply
              0
              • L Lost User

                Wjousts wrote:

                Has anybody else seen something like this?

                Yup. Often in custom controls, someplace setting a property once it's shown. The Designer picks up the change, and marks the document as dirty. Checking the DesignMode[^] would be a quick work-around. If the form goes dirty, can you undo it?

                Bastard Programmer from Hell :suss:

                W Offline
                W Offline
                Wjousts
                wrote on last edited by
                #7

                I have some custom controls and some forms that inherit from other forms. You might be on to something there.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups