void InitPicture() { //pbCodeImg.Visible = false; pbCodeImg.PictureBoxImage(AppConfig.CodeImg12306Dir); int w = pbCodeImg.Width, h = pbCodeImg.Height; avgX = w / AppConfig.ImgNormal[0]; avgY = CalculateIconHeight(h); //几行几列图片 for (int row = 0; row <= AppConfig.ImgNormal[1]; row++) { for (int column = 0; column <= AppConfig.ImgNormal[0]; column++) { int x = avgX * column + avgX / 2; int y = avgY * row + avgY / 2; PictureBox icon = new PictureBox(); ((System.ComponentModel.ISupportInitialize)(icon)).BeginInit(); icon.Size = new Size(22, 22); icon.PictureBoxImage(AppConfig.IConDir); icon.Location = new Point(x + 500, y); icon.Name = EleTag.Icon.ToString() + (row * column); icon.TabStop = false; this.Controls.Add(icon); ((System.ComponentModel.ISupportInitialize)(icon)).EndInit(); } } //生成小图标 this.ResumeLayout(false); }