I have a piece of code that adds controls to a form at run time based on the number of images that I have in an image list:
for(int i2=0; i2 < il.Images.Count; i2++)
pb2 = new PictureBox();
thumbWidth = (il.Images[i2].Height/il.Images[i2].Width) * thumbHeight;
pb2.Size = new Size((int)thumbWidth,(int)thumbHeight);
pb2.SizeMode = PictureBoxSizeMode.StretchImage;
pb2.Image = il.Images[i2];
pb2.Name = i2.ToString();
if (i2 == 0)
pb2.Location = new Point(10, (int)thumbHeight *i2 +30);
pb2.Location = new Point(10, ((int)thumbHeight +5) *i2 +30);
pb2.BackColor = Color.Blue;pb2.Click += new System.EventHandler(picButt_click); this.panel2.Controls.Add(pb2);
This works fine.
However, the thing I dont know is how to determine which picture box was actually clicked on.
privatevoid picButt_click(object sender, System.EventArgs e) sender and eventsargs doesn't seem to pass the actual name of the control.
thanks in advance,
Can anyone tell me?