Visual Studio insists my form has changed
-
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?
-
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?
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."
-
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?
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.
-
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?
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:
-
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?
-
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."
-
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: