Get all controls of a specific type

Using a bit of LINQ:

foreach(var pb in this.Controls.OfType<PictureBox>())
{
  //do stuff
}

However, this will only take care of PictureBoxes in the main container.

Leave a Comment