开发者

[File].Designer.cs corrupting self - Designer hell

I have a winforms application that I am writing in C# - in Visual Studio 2010. I have one specific form that keeps corrupting itself every other day or so - according to TFS, it looks like most of the file is re-written by the designer when I have made only the smallest changes. (location of buttions, etc.) Things fall off strips, toolbars, etc. as well as errors just trying to use the designer. See my other post H开发者_如何学Cere. (Thought I figured this out, but I guess not)

Here is an example piece of code that goes missing - when I put it back in, it takes it back out when I save the file. The code was generated by the designer in a previous file version.

this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
        this.tssEmployeeName,
        this.tssLoadTime,
        this.tssSpring,
        this.tssHomeLocation,
        this.tssTotal,
        this.tssDue});

Is there any way of 're-generating' the [file].Designer.cs file? Or should I bite the bullet and re-do this form? (pain with over 100 components on this one...) It's the only form I have a problem with out of the 35 or so in the project.

VS 2010 w\ SP1.

Thanks, Andrew


I've experienced this before, although I'm not sure if my issues were exactly the same.

Try putting a handful of problem controls, such as your StatusStrip control and its children, into separate User Controls. Then add those User Controls to the main form instead. At the very least, you can prevent the designer from rewriting those controls.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜