c# 如何获得menustrip一级菜单菜单
比如商店食品零食牛奶日化牙膏洗发水选择了某一项之后怎么知道选择的是食品类的还是日化类的呢已解决.OwnerItem就可以了...
比如
商店
食品
零食
牛奶
日化
牙膏
洗发水
选择了某一项之后怎么知道选择的是食品类的还是日化类的呢
已解决 .OwnerItem就可以了 展开
商店
食品
零食
牛奶
日化
牙膏
洗发水
选择了某一项之后怎么知道选择的是食品类的还是日化类的呢
已解决 .OwnerItem就可以了 展开
1个回答
展开全部
你可以先在设计器里手动添加,然后在Designer.cs里找到相应代码剪切过来就行,如下
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem aAAToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem bBBToolStripMenuItem;
private void button1_Click(object sender, EventArgs e)
{
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.aAAToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.bBBToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.aAAToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(524, 24);
this.menuStrip1.TabIndex = 3;
this.menuStrip1.Text = "menuStrip1";
//
// aAAToolStripMenuItem
//
this.aAAToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.bBBToolStripMenuItem});
this.aAAToolStripMenuItem.Name = "aAAToolStripMenuItem";
this.aAAToolStripMenuItem.Size = new System.Drawing.Size(40, 20);
this.aAAToolStripMenuItem.Text = "AAA";
//
// bBBToolStripMenuItem
//
this.bBBToolStripMenuItem.Name = "bBBToolStripMenuItem";
this.bBBToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.bBBToolStripMenuItem.Text = "BBB";
this.bBBToolStripMenuItem.Click += new System.EventHandler(this.bBBToolStripMenuItem_Click);
//
//Form1
//
this.Controls.Add(this.menuStrip1);
}
private void bBBToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("BBB");
}
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem aAAToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem bBBToolStripMenuItem;
private void button1_Click(object sender, EventArgs e)
{
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.aAAToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.bBBToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.aAAToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(524, 24);
this.menuStrip1.TabIndex = 3;
this.menuStrip1.Text = "menuStrip1";
//
// aAAToolStripMenuItem
//
this.aAAToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.bBBToolStripMenuItem});
this.aAAToolStripMenuItem.Name = "aAAToolStripMenuItem";
this.aAAToolStripMenuItem.Size = new System.Drawing.Size(40, 20);
this.aAAToolStripMenuItem.Text = "AAA";
//
// bBBToolStripMenuItem
//
this.bBBToolStripMenuItem.Name = "bBBToolStripMenuItem";
this.bBBToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.bBBToolStripMenuItem.Text = "BBB";
this.bBBToolStripMenuItem.Click += new System.EventHandler(this.bBBToolStripMenuItem_Click);
//
//Form1
//
this.Controls.Add(this.menuStrip1);
}
private void bBBToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("BBB");
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询