2

我想在 . 这些带有图像的图片框内列出列表,PictureBox这些FlowLayoutPanel图片框是在运行时动态添加的。现在我遇到的问题是,我必须在面板中添加更多的图片框,当我这样做时,最后的图片框似乎丢失了,尽管看起来这些图像的空间已经分配。那么我该如何克服这个问题问题。

panel1.Controls.Clear();
        Point NewLocation = new System.Drawing.Point(0, 0);
        int CurrentImgIndex = 0;
        foreach (ScannedImages image in Global.ScannedReportList[0].ImageCollection)
        {
            panel1.SuspendLayout();
            PictureBox pbTemp = new PictureBox();
            pbTemp.BackColor = System.Drawing.Color.Transparent;
            pbTemp.Location = NewLocation;
            pbTemp.Name = "picImage";
            pbTemp.Size = new System.Drawing.Size(757*2, 980*2);
            pbTemp.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
            pbTemp.TabIndex = 7;
            pbTemp.TabStop = false;
            pbTemp.Tag = CurrentImgIndex + 1;
            pbTemp.DragDrop += new System.Windows.Forms.DragEventHandler(this.PbTemp_DragDrop);
            pbTemp.DragOver += new System.Windows.Forms.DragEventHandler(this.PbTemp_DragOver);

            pbTemp.Click += new EventHandler(this.pbTemp_Click);

            try
            {
                //pm
                Image img = Global.ScannedReportList[0].ImageCollection[CurrentImgIndex].GetImageObject();

                txtCurrentPage.Text = (CurrentImageIndex + 1).ToString();


                //pm image
                RotateAngle = Global.ScannedReportList[0].ImageCollection[CurrentImgIndex].RotationAngle;
                //drpGroupTool.SelectedIndex = Global.ScannedReportList[0].ImageCollection[CurrentImgIndex].DocumentGroup;
                switch (RotateAngle)
                {
                    case 90:
                        img.RotateFlip(RotateFlipType.Rotate90FlipNone);
                        break;
                    case 180:
                        img.RotateFlip(RotateFlipType.Rotate180FlipNone);
                        break;
                    case 270:
                        img.RotateFlip(RotateFlipType.Rotate270FlipNone);
                        break;
                }
                //pm

                m_szOriginal = img.Size;
                pbTemp.Image = img;
                if (Brightness != 0)
                    pbTemp.Image = AdjustBrightness(new Bitmap(pbTemp.Image), Brightness);

                if (Contrast != 0)
                    pbTemp.Image = AdjustContrast1(new Bitmap(pbTemp.Image), Contrast);
                panel1.Controls.Add(pbTemp);
                panel1.ResumeLayout();

                this.panel1.PerformLayout();
                this.panel1.Refresh();
                //pm
                if (RotateAngle == 90 || RotateAngle == 270)
                {
                    NewLocation.Y += img.Width;
                }
                else if (RotateAngle == 0 || RotateAngle == 180)
                {
                    NewLocation.Y += img.Height;
                }
                //
                CurrentImgIndex++;
                this.Refresh();
                index[CurrentImgIndex] = CurrentImgIndex + 1;
            }
            catch
            {
                pbTemp.Image = null;
            }
4

0 回答 0