时间:2021-02-14 11:31:05 | 栏目:.NET代码 | 点击:次
本文实例讲述了C#动态生成PictureBox并指定图片的方法。分享给大家供大家参考。具体如下:
int Num = 0; PictureBox[] pb; Num = 6; pb = new PictureBox[Num]; for (int i = 1; i < Num; i++) { pb[i] = new System.Windows.Forms.PictureBox(); pb[i].BorderStyle = BorderStyle.FixedSingle; pb[i].Location = new Point(50 + i * 110, 100); pb[i].SizeMode = PictureBoxSizeMode.Zoom; pb[i].Image = Image.FromFile(@"D:\pic\" + i + ".png"); FlowPanel1.Controls.Add(pb[i]); }
希望本文所述对大家的C#程序设计有所帮助。