1

Here is My Designer.cs code.

this.gbFacets.Location = new System.Drawing.Point(590, 69);
this.gbFacets.Name = "gbFacets";
this.gbFacets.Size = new System.Drawing.Size(255, 355);
this.gbFacets.TabIndex = 7;
this.gbFacets.TabStop = false;
this.gbFacets.Text = "Facets Found";
this.gbFacets.Enter += new System.EventHandler(this.gbFacets_Enter);

here is my Formmain code

private void AddFacetsToPictureBoxes(List<PictureBox> pictureBoxes)
{
    foreach (var pic in pictureBoxes)
        this.gbFacets.Controls.Add(pic);
}

i got the pics added to Groupbox but if no of pics increases then, it shows only some pics. so please tell me how can i make this groupbox scrollable to view all pics.

4

1 回答 1

1

由于 groupbox 没有可滚动属性,请将图像添加到面板并设置可滚动属性。

然后让面板填充组框。

编辑:像这样

private void AddPicturesToGroupBox(List<PictureBox> pictureBoxes)
{
    Panel myPanel = new Panel();
    myPanel.Dockstyle = Dockstyle.Fill;
    myPanel.AutoScroll = true; //this allows the panel to display scrollbars when it needs to

    foreach (var pic in pictureBoxes)
    {
        myPanel.Controls.Add(pic); //put your pictures onto the panel
    }

    this.gbFacets.Controls.Clear();
    this.gbFacets.Controls.Add(myPanel); //put your panel inside the Groupbox
}
于 2013-10-30T11:36:04.043 回答