Last night, I was working on my project in C# by visual studio 2012. Suddenly I encountered a few errors from visual studio and then menu strip went into hiding. Now I haven't menu strip in my form and I lost all it visual option, but I have all it code in my `formdesigner.cs` file. I can't make all option again because it is hard and Time-consuming and I must create a menu strip by new names.and create all sub items by new names.How I can resume my lost menu strip to form?
This is a part of my designer code:
this.Main = new System.Windows.Forms.ToolStripMenuItem();
this.userOptionTtm = new System.Windows.Forms.ToolStripMenuItem();
.
.
.
and i have properties for all sub items of menu , that i was created (or defined ) previously. for example :
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 = "تنظیمات";
.
.
.
and in my form code, I have all code of this menu. for example:
private void FeutureJobsTSM_Click(object sender, EventArgs e)
{
FeutureReportForm.isJobs = true;
FeutureReportForm fr = new FeutureReportForm();
fr.ShowDialog(this);
}
please attention :
There is no code same :
this.component.add(this.Main);
When i add this line , This error occurred :
Object reference not set to an instance of an object.
Look at this picture
this exception occurred when I build App.
If i add this line :
this.controls.add(this.Main);
I see 2 Errors in list error :
Error 1 : The best overloaded method match for 'System.Windows.Forms.Control.ControlCollection.Add(System.Windows.Forms.Control)' has some invalid arguments
Error 2 : Argument 1: cannot convert from 'System.Windows.Forms.ToolStripMenuItem' to 'System.Windows.Forms.Control'
This is my Designer code about Menu strip (Main):
this.Main = new System.Windows.Forms.ToolStripMenuItem();
And some code for define sub Menus. I'm surprised that Why don't exist menu strip icon under my form in Form.cs[Design] windows.
Look at this picture
And this