c# 通过代码创建了很多的pictureBox,如何单击button控制那些pictureBox?

2024-12-30 05:36:11
推荐回答(1个)
回答1:

代码如下:

       private void button1_Click(object sender, EventArgs e)
        {
            // 遍历窗体所以控件
            foreach (Control c in this.Controls)
            {
                // 检查控件是否为PictureBox
                if (c is PictureBox)
                {
                    // 是,着向左边移动
                    c.Left += 10;
                }
            }
        }