昨晚,我在 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();
}