-1

昨晚,我在 Visual Studio 2012 的 C# 项目中工作。突然我遇到了一些来自 Visual Studio 的错误,然后菜单条就隐藏了。现在我的表单中没有菜单条,并且我丢失了所有可视选项,但我的formdesigner.cs文件中包含所有代码。我无法再次选择所有选项,因为它既困难又耗时,我必须用新名称创建菜单条。并用新名称创建所有子项。

如何恢复丢失的菜单条以形成?

这是我的设计器代码的一部分:

 this.Main = new System.Windows.Forms.ToolStripMenuItem();
 this.userOptionTtm = new System.Windows.Forms.ToolStripMenuItem();
 this.changePasswprdTSM = new System.Windows.Forms.ToolStripMenuItem();
 this.CalenderOption = new System.Windows.Forms.ToolStripMenuItem();
 this.CalenderOption2 = new System.Windows.Forms.ToolStripMenuItem();
 this.CalenderOption1 = new System.Windows.Forms.ToolStripMenuItem();
 this.hollydays = new System.Windows.Forms.ToolStripMenuItem();
 this.ExitTsm = new System.Windows.Forms.ToolStripMenuItem();
 this.useroption = new System.Windows.Forms.ToolStripMenuItem();
 this.ReportsTSM = new System.Windows.Forms.ToolStripMenuItem();
 this.loanListTsm = new System.Windows.Forms.ToolStripMenuItem();
 this.FeutureJobsTSM = new System.Windows.Forms.ToolStripMenuItem();

我有菜单的所有子项的属性,我之前创建(或定义)。例如 :

//
// Main
//
this.Main.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.userOptionTtm,
this.CalenderOption,
this.ExitTsm});
this.Main.Font = new System.Drawing.Font("Segoe UI", 9F);
this.Main.Name = "Main";
this.Main.Size = new System.Drawing.Size(62, 20);
this.Main.Text = "تنظیمات";
//
// userOptionTtm
//
this.userOptionTtm.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.changePasswprdTSM});
this.userOptionTtm.Font = new System.Drawing.Font("Segoe UI", 10F);
this.userOptionTtm.Image = global::TimeManagment.Properties.Resources._0079;
this.userOptionTtm.Name = "userOptionTtm";
this.userOptionTtm.Size = new System.Drawing.Size(165, 24);
this.userOptionTtm.Text = "تنظیمات کاربر";
this.userOptionTtm.Click += new System.EventHandler(this.chengePasswordTtm_Click_1);

在我的表单代码中,我有这个菜单的所有代码。例如:

private void FeutureJobsTSM_Click(object sender, EventArgs e)
{
    FeutureReportForm.isJobs = true;
    FeutureReportForm fr = new FeutureReportForm();
    fr.ShowDialog(this);
}

或者

private void changePasswprdTSM_Click(object sender, EventArgs e)
{
    chengePasswordForm cpf = new chengePasswordForm();
    cpf.ShowDialog();
}
4

1 回答 1

0

谢谢大家。我将这些行添加到 Form.Designer.cs 文件中,我的问题得到了解决。

this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.menuStrip1.BackColor = System.Drawing.Color.Transparent;
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] 
{ this.Main,this.ReportsTSM });
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
this.menuStrip1.Size = new System.Drawing.Size(589, 24);
this.menuStrip1.TabIndex = 10;
this.menuStrip1.Text = "menuStrip1";
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.Controls.Add(this.menuStrip1);     
private System.Windows.Forms.MenuStrip menuStrip1;
于 2013-10-27T14:59:48.423 回答