title: Adding a right click menu item to a picture box
body: <p>When I right-click on a picturebox, by using context menu items I am showing a menu item saveImageAs. </p>
  
  <p><strong>Problem:</strong> When I right click on the picture box, it shows saveImageAs, when I click saveImageAs it will hit</p>
  
  <pre><code>private void saveImageAsToolStripMenuItem_Click(object sender, EventArgs e)
  {
      //what should i use instead of click to hit form_Mouseclick
  
      pictureBox1.Click += form_MouseClick;
      pictureBox2.Click += form_MouseClick;
  }
  </code></pre>
  
  <p>Here what should I use instead of <code>pictureBox1_click()</code> to hit <code>form_MouseClick()</code>. If anyone could help I would be most grateful.   </p>
  
  <pre><code>private void saveImageAsToolStripMenuItem_Click(object sender, EventArgs e)
  {
      pictureBox1.Click += form_MouseClick;
      pictureBox2.Click += form_MouseClick;    
  } 
  
  private void form_MouseClick(object sender, MouseEventArgs e)
  {
      PictureBox pb = sender as PictureBox;
      SaveFileDialog sfd = new SaveFileDialog();
      sfd.Filter = "Images|*.png;*.bmp;*.jpg";
      if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
      {
          string filepath = System.IO.Path.GetExtension(sfd.FileName);
      }
      if(pb != null &amp;&amp; sfd.FileName != null)
      {
          Image im = pb.Image;
          SaveImage(im, sfd.FileName);
      }
  }
  
  private static void SaveImage(Image im, string destPath)
  {
      im.Save(destPath, System.Drawing.Imaging.ImageFormat.Png);
  }
  </code></pre>