title: c# how to add contextMenuStrip item at runtime?
body: <p>I am sure that the answer to this has been posted before. Forgive me as I think I am just not thinking of the right search string. </p>
  
  <p>What I have is a context menu strip assigned to my tray icon for my dialer. The idea is for the user to set various numbers and select the user defined numbers from the menu and initiate the dial. </p>
  
  <p>So the menu pops up with <code>Presets</code>, <code>Setup</code>, &amp; <code>Exit</code>. I want the Presets menu to open a new tree listing the user defined number. I also want this to populate from an xml file every time the application is loaded. </p>
  
  <p>My problem is that I have no idea how to dynamically populate a sub menu item and give it a function.</p>
  
  <p>So how would I at start up add user defined numbers to preset -> (<code>userNumber1, usernumber2, userNumber3</code>) and then call the <code>dial()</code> function when clicked?</p>
  
  <hr>
  
  <p>So I found how to add to the list... I now feel silly for asking that. For anyone else who wants to know that one, The list item is given a name. Im my case the name attribute is " presetsToolStripMenuItem"</p>
  
  <p>So to add an item to it call the name </p>
  
  <pre><code>presetsToolStripMenuItem.DropDownItems.Add(string text)
  </code></pre>
  
  <p>No to move on. I am stuck now trying to figure out how to assign an event to that newly added function. I did find</p>
  
  <pre><code>presetsToolStripMenuItem.DropDownItems.Add(string text, image, eventargs)
  </code></pre>
  
  <p>I am struggling with this one. Maybe I need to stop and come back to it later. Perhaps if someone could provide me with an example of using this line to call a <code>function();</code> I would be most appreciative.  </p>