foreach里面遍历panel的控件集合controls比如foreach(var i in panel1.controls){ if(i.GetType()==typeof(PictureBox)//判断类型为picturebox时执行下一步操作}