Accessing certain instance of a Winform control

Viewed 52

In this program im writing I use a function to create multiple instances of a PictureBox. This is the code:

public void serverCard()
{
    //Definitions
    PictureBox cardBack = new PictureBox();

    //Specifics for card
    cardBack.Size = new Size(cardSizeX, cardSizeY);
    cardBack.BackColor = Color.White;
    cardBack.Left = startX;
    cardBack.Top = startY;

    serverArea.Controls.Add(cardBack);

    //differences in pos
    startX += cardBack.Width + 5;
    if (startX > this.Width - cardSizeX)
    {
      startY += cardBack.Height + 5;
      startX = 5;
    }
}

How would I access a specific instance of the PictureBox. For Example: I create 5 PictureBoxes called "cardBack" using this function. I want to change the position of the second Picture Box that was created, how would I go about this.

2 Answers
Related