title: C# : get the file path of picturebox onclick
body: <p>I have created a function that loops a folder and retrieves each image file and draw a picturebox on the form.
  Here is the function :</p>
  
  <pre><code>    private void Create_Controls(string Img_path)
      {
          PictureBox p = new PictureBox();
          p.Size = new Size(138, 100);
          p.Location = new Point(6, 6);
          p.BackgroundImage = Image.FromFile(Img_path);
          p.BackgroundImageLayout = ImageLayout.Stretch;
  
          this.Controls.Add(p);
      }
  </code></pre>
  
  <p>So what i need to do is : whenever i click on any picturebox on the form , a message popup with the image file path.</p>
  
  <p>So i thought about adding a custom event :</p>
  
  <pre><code>p.Click += delegate { Pop_Up(); };
  </code></pre>
  
  <p>AND</p>
  
  <pre><code>    private void Pop_Up()
      {
          /* POP UP MESSAGE WITH Picturebox image file path*/
      }
  </code></pre>