OK so I have a MenuStrip called Form1.menuStrip1. Form1.menuStrip1 has two items horizontally called Menu and Lists. What I want to do is add a new submenu item to the Lists menu. I have a string called mystring, and I want that to be the title of the new Item.
Something like this
void AddItem(string mystring)
{
// add mystring
}
here is the sample
ToolStripMenuItem fileToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
ToolStripMenuItem loadLogsToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
fileToolStripMenuItem1.Name = "File";
loadLogsToolStripMenuItem1.Name ="Logs";
this.fileToolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.loadLogsToolStripMenuItem1
}
then you would have File->Logs if you want to add more subItem to File just use add more after this.loadLogsToolStripMenuItem1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With