本文介绍了Picturebox有时不会显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了简单的漫画阅读器,其中包含多个PictureBox,每个页面都包含图像。 PictureBox然后从上到下添加到flowlayoutpanel。
问题是有一些图像没有显示,当我调整图像显示的形式时。
imglayout = FlowLayoutPanel
我的尝试:
i have create simple manga reader with multiple PictureBox to contain image each page. The PictureBox then added to flowlayoutpanel top to bottom.
The Problem is there's some image that doesnt show and when i resize the form the image showed.
Screenshoot to help imglayout = FlowLayoutPanel
What I have tried:
chapterList.AddRange(Directory.GetDirectories("Gosu"));
chapterList.Sort(new NumComparer());
//load chapter pertama
//simpan image di ram
foreach (string item in Directory.GetFiles(chapterList[numChapter]))
{
imgList.Add(item);
}
imgList.Sort(new NumComparer());
//buat picturebox
this.SuspendLayout();
foreach (string i in imgList)
{
Image img = Image.FromFile(i);
PictureBox box = new PictureBox();
box.Width = img.Width;
box.Height = img.Height;
box.BorderStyle = BorderStyle.FixedSingle;
box.Image = img;
if (boxwidth < img.Width) { boxwidth = img.Width; }
imgLayout.Controls.Add(box);
}
this.Width = boxwidth+300;
this.MinimumSize = new Size(boxwidth+300, 550);
推荐答案
private void ShowAlbum(Image[] thumbnails) {
List<PictureBox> pictureBoxList = new List<PictureBox>();
foreach (Image img in thumbnails) {
PictureBox box = new PictureBox();
box.Image = img;
pictureBoxList.Add(box);
}
flowPanel.Hide();
flowPanel.Controls.AddRange(pictureBoxList.ToArray());
// pbox handles are created when the container control is reshown
flowPanel.Show();
}
Alan。
Alan.
这篇关于Picturebox有时不会显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!