Hi dcurran,
This information is stored in the sender variable. Sender is always the
control that triggered the current run of the method.
private void pictureBox1_Click(object sender, System.EventArgs e)
{
if(sender == pictureBox1)
SelectedPicture = 0;
else if(sender == pictureBox2)
SelectedPicture = 1;
}
You might also use the Tag property to store useful information, for
instance a number
private void pictureBox1_Click(object sender, System.EventArgs e)
{
SelectedPicture = (int)((PictureBox)sender).Tag;
}
On Sun, 6 Feb 2005 21:59:03 -0800, dcurran
<dc*****@discussions.microsoft.com> wrote:
I have 68 picturebox objects in an array and I want to work with the
picturebox that is clicked on. How can I figure out which picturebox was
clicked on so that I can make one generic "click" routine instead of
having
68 separate events like this?
private void pictureBox1_Click(object sender, System.EventArgs e)
{SelectedPicture = 0;}
private void pictureBox2_Click(object sender, System.EventArgs e)
{SelectedPicture = 1;}
.
.
.
etc
--
Happy Coding!
Morten Wennevik [C# MVP]