title: Adding submenu to a particular menuitem of contextmenu strip
body: <p>I have a contextmenu strip in which menu items will be populated based on certain condition.</p>
  
  <p>Ex:</p>
  
  <p>for the condition1:</p>
  
  <pre><code>myContextMenuStrip.Items.Clear();
  myContextMenuStrip.Items.Add("Item title", null, myClickHandler);
  myContextMenuStrip.Items.Add("Item Status", null, myClickHandler);
  myContextMenuStrip.Items.Add("Item Variables", null, myClickHandler);
  </code></pre>
  
  <p>Condition2:</p>
  
  <pre><code>myContextMenuStrip.Items.Clear();
  myContextMenuStrip.Items.Add("Item Status", null, myClickHandler);
  </code></pre>
  
  <p>For the condition1 to add a submenu to ItemStatus i use</p>
  
  <pre><code>(myContextMenuStrip.Items[1] as ToolStripMenuItem).DropDownItems.Add("Submenu1", null, new EventHandler(gridcontextsubMenu_ItemClicked));
  (myContextMenuStrip.Items[1] as ToolStripMenuItem).DropDownItems.Add("Submenu2", null, new EventHandler(gridcontextsubMenu_ItemClicked));
  </code></pre>
  
  <p>For the condition2 to add a submenu to ItemStatus i use</p>
  
  <pre><code>(myContextMenuStrip.Items[0] as ToolStripMenuItem).DropDownItems.Add("Submenu1", null, new EventHandler(gridcontextsubMenu_ItemClicked));
  (myContextMenuStrip.Items[0] as ToolStripMenuItem).DropDownItems.Add("Submenu2", null, new EventHandler(gridcontextsubMenu_ItemClicked));
  </code></pre>
  
  <p>But i need a general way to add submenu to the menu item ItemStatus.</p>
  
  <p>Kindly share the answer </p>