title: How to remove a tabpage from a context menu
body: <p>I have written the code to display a context menu on right click of my tabpages. How would I go about actually removing the tabpage when the user clicks "Remove Tab" from the context menu? I have gotten this far. (unloadProfile is my context menu item). I am unsure how to get the tabpage the context menu is associating with to remove it. Any help is appreciated.</p>
  
  <pre><code>// My Context Menu
  private void tabControl_MouseClick(object sender, MouseEventArgs e)
      {
          if (e.Button == MouseButtons.Right)
          {
              // iterate through all the tab pages
              for (int i = 0; i &lt; tabControl.TabCount; i++)
              {
                  // get their rectangle area and check if it contains the mouse cursor
                  Rectangle r = tabControl.GetTabRect(i);
                  if (r.Contains(e.Location))
                  {
                      // show the context menu here
                      this.contextMenuStrip1.Show(this.tabControl, e.Location);
                  }
              }
          }
      }
  
  // Context menu click event
  private void unloadProfile_Click(object sender, EventArgs e)
      {
          // iterate through all the tab pages
          for (int i = 0; i &lt; tabControl.TabCount; i++)
          {
  
          }
      }
  </code></pre>