C# 在面板中滚动图像

C# 在面板中滚动图像,c#,winforms,visual-studio,C#,Winforms,Visual Studio,我在flowLayoutPanel中动态加载多个图像…如果需要,我想滚动面板 这是我的密码: private void carregarImagensToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog d = new OpenFileDialog(); // allow multiple selection d.Multiselect = true;

我在flowLayoutPanel中动态加载多个图像…如果需要,我想滚动面板

这是我的密码:

 private void carregarImagensToolStripMenuItem_Click(object sender, EventArgs e)
    {
        OpenFileDialog d = new OpenFileDialog();

        // allow multiple selection
        d.Multiselect = true;

        // filter the desired file types
        d.Filter = "JPG |*.jpg|PNG|*.png|BMP|*.bmp";

        // show the dialog and check if the selection was made

        if (d.ShowDialog() == DialogResult.OK)
        {
            foreach (string image in d.FileNames)
            {
                // create a new control
                PictureBox pb = new PictureBox();

                pb.Tag = tag;
                btn.Tag = tag;
                pb.MouseDown += pictureBox_MouseDown;
                // assign the image
                pb.Image = new Bitmap(image);

                listaImagens.Add(new Bitmap(image));

                // stretch the image
                pb.SizeMode = PictureBoxSizeMode.StretchImage;

                // set the size of the picture box
                pb.Height = pb.Image.Height / 10;
                pb.Width = pb.Image.Width / 10;

                // add the control to the container
                flowLayoutPanel1.Controls.Add(pb);
                listaPicBoxes.Add(pb);
                tag++;

            }

        }

    }

将FlowLayoutPanel的AutoScroll属性设置为true

将FlowLayoutPanel的AutoScroll属性设置为true

您始终可以使用
AutoScroll
属性:

flowLayoutPanel1.AutoScroll = true;

您可以始终使用
AutoScroll
属性:

flowLayoutPanel1.AutoScroll = true;