Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# FlowLayoutPanel的问题_C#_Winforms - Fatal编程技术网

C# FlowLayoutPanel的问题

C# FlowLayoutPanel的问题,c#,winforms,C#,Winforms,我希望在FlowLayoutPanel中有图片框的列表。这些带有图像的图片框在运行时动态添加。现在我遇到的问题是,我必须在面板中添加不止一个picturebox,当我这样做时,末尾的图片框似乎丢失了,尽管看起来这些图片的空间已分配。那么我如何克服这个问题呢 panel1.Controls.Clear(); Point NewLocation = new System.Drawing.Point(0, 0); int CurrentImgIndex = 0;

我希望在
FlowLayoutPanel
中有
图片框的列表。这些带有图像的图片框在运行时动态添加。现在我遇到的问题是,我必须在面板中添加不止一个picturebox,当我这样做时,末尾的图片框似乎丢失了,尽管看起来这些图片的空间已分配。那么我如何克服这个问题呢

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;
            }

更多细节。如果你能发布一些代码,那就太好了。请使用编辑功能。我也添加了代码。现在有用吗?好的,我找到了解决方案。我在面板的滚动事件中添加了FlowLayoutPanel.PerformLayout(),效果很好。@Prabim酷。你能把答案放在答题箱里吗。然后人们知道这个问题已经得到了回答。更多细节。如果你能发布一些代码,那就太好了。请使用编辑功能。我也添加了代码。现在有用吗?好的,我找到了解决方案。我在面板的滚动事件中添加了FlowLayoutPanel.PerformLayout(),效果很好。@Prabim酷。你能把答案放在答题箱里吗。然后人们知道这个问题已经得到了回答。