title: C# - Dynamically add and remove items from ContextMenuStrip and "Smart Events"
body: <p>In short my problem is how to implement "Send to" (right click on file on windows)</p>
  
  <p>I have a data grid view that also contain a column with log file name (I know the path for each file)</p>
  
  <p>I want to add to my pop-up menu Copy options to Desktop and Disk on Key (removable) drivers.</p>
  
  <p>My pop-up menu might look like this:</p>
  
  <pre><code>   View log
  
     Open file location
  
     &lt;----------------&gt;
  
     Copy to --&gt;  Desktop
                  (and Removable Drivers)
  
     ...
  </code></pre>
  
  <p>So I want:</p>
  
  <ol>
  <li><p>to add a list with "Desktop" and all removable drivers under "Copy to" sub menu (and to remove removable drivers that the user eject them)</p></li>
  <li><p>As I say I want to copy the file to the removable driver, So How can I add "dynamically event" - I meaning - if the user plug in 4 Disk On Key drivers I have new 4 lines under "Copy to" sub menu (Let's say, Desktop and E:\, F:\, G:\, L:), So I need new click event for each Removable driver to copy the file to the true driver...</p></li>
  </ol>
  
  <p>About Question 1 - I found the code that detect if removable driver plug in the computer and I success to add the removalble drivers to the sub menu. But I unsuccessful in removing the items from the sub menu:</p>
  
  <pre><code>private void menu_PopUp_Opening(object sender, CancelEventArgs e)
  {
      // Need to remove all removable drivers first --&gt; How to do ?
  
      // to update the USB drivers when opening new pop up menu
      DriveInfo[] ListDrives = DriveInfo.GetDrives();
      foreach (DriveInfo Drive in ListDrives)
      {
          if (Drive.DriveType == DriveType.Removable)
          {
              // add to popup menu, from: http://stackoverflow.com/questions/5868446/how-to-add-sub-menu-items-in-contextmenustrip-using-c4-0
              (menu_PopUp.Items[3] as ToolStripMenuItem).DropDownItems.Add(Drive.Name + " (" + Drive.VolumeLabel + ")");
          }
      }
  }
  </code></pre>
  
  <p>Thank you any help !</p>