MenuStrip.Items集合中的项目自发消失-VS2010 [英] Items in MenuStrip.Items collection spontaneously disappear - VS2010
问题描述
是否还有其他人注意到VS2010中的一个问题,即MenuStrip的Items集合的内容自发消失了?
Has anyone else noticed a problem in VS2010 with the contents of a MenuStrip’s Items collection spontaneously disappearing? One minute the items are present, and the next time I open the solution, they’re gone.
发生了我两次...大约一个月前一次,几天前一次(相同的解决方案).它似乎只影响MenuStrip; 似乎没有其他控件受到影响.
It's happened to me twice... once about a month back and again a few days ago (same solution). It only seems to affect the MenuStrip; no other controls appear to be affected.
我可以提供已损坏"的广告设计器文件,但 论坛编辑器不会让我将所有内容都包括在内! (boo)
I can provide the "damaged" designer file, but the forum editor won't let me include all of it! (boo)
DT
推荐答案
在菜单项消失之前,我回到了由解决方案制成的备份,这是我在损坏的文件中发现的问题...
I fell back to a backup I made of the solution before the menustrip items disappeared, and here's the problems I found in the damaged file...
1) 恰好在InitializeComponent的初始部分结束之前,缺少粗体的行:
1) just before the end of the initial section in InitializeComponent, the line in bold was missing:
this.QueryForDataBackgroundWorker = new System.ComponentModel.BackgroundWorker();
(((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.SuspendLayout();
(((System.ComponentModel.ISupportInitialize)(this.YAxisGrid)).BeginInit();
(((System.ComponentModel.ISupportInitialize)(this.XAxisGrid)).BeginInit();
this.menuStrip1.SuspendLayout();
this.contextMenuStrip1.SuspendLayout();
this.SuspendLayout();
this.QueryForDataBackgroundWorker = new System.ComponentModel.BackgroundWorker();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.YAxisGrid)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.XAxisGrid)).BeginInit();
this.menuStrip1.SuspendLayout();
this.contextMenuStrip1.SuspendLayout();
this.SuspendLayout();
2)缺少以下粗体行:
2) the following lines in bold were missing:
//
//menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem [] {
this.MenuItem_File,
this.MenuItem_Print,
this.MenuItem_View});
this.menuStrip1.Location =新的System.Drawing.Point(0,0);
this.menuStrip1.Name ="menuStrip1";
this.menuStrip1.Size =新的System.Drawing.Size(1031,24);
this.menuStrip1.TabIndex = 2;
this.menuStrip1.Text ="menuStrip1";
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.MenuItem_File,
this.MenuItem_Print,
this.MenuItem_View});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(1031, 24);
this.menuStrip1.TabIndex = 2;
this.menuStrip1.Text = "menuStrip1";
3)缺少以下粗体行:
3) the following lines in bold was missing:
//
//MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F,13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1031,469);
this.Controls.Add(this.splitContainer1);
this.Controls.Add(this.menuStrip1);
this.Icon =((System.Drawing.Icon)(resources.GetObject("
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1031, 469);
this.Controls.Add(this.splitContainer1);
this.Controls.Add(this.menuStrip1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("
this.Icon"))));
this.Name ="MainForm";
this.Text ="MainForm.Text";
this.FormClosing + =新的System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
this.Load + =新的System.EventHandler(this.MainForm_Load);
this.Resize + = new System.EventHandler(this.MainForm_Resize);
this.splitContainer1.Panel1.ResumeLayout(false);
(((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
(((System.ComponentModel.ISupportInitialize)(this.YAxisGrid)).EndInit();
(((System.ComponentModel.ISupportInitialize)(this.XAxisGrid)).EndInit();
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.contextMenuStrip1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
this.Icon")));
this.Name = "MainForm";
this.Text = "MainForm.Text";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
this.Load += new System.EventHandler(this.MainForm_Load);
this.Resize += new System.EventHandler(this.MainForm_Resize);
this.splitContainer1.Panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.YAxisGrid)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.XAxisGrid)).EndInit();
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.contextMenuStrip1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
添加缺少的行似乎已解决了该问题!
恕我直言,这看起来像是VS2010中的错误.我可以看到VS的随机崩溃如何损坏设计器文件.但这两次发生在同一控件上,而且我不记得VS或系统崩溃.
IMHO, this looks suspiciously like a bug in VS2010. I can see how a random crash of VS might damage the designer file. But this has happened to the same control twice, and I don't recall a VS or system crash.
何时需要VS2010 SP?
When we expect a VS2010 SP?
DT
这篇关于MenuStrip.Items集合中的项目自发消失-VS2010的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!