Click here to Skip to main content
15,847,427 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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:

C#
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);
Posted
Updated 24-Feb-17 3:57am
Comments
Ralf Meier 24-Feb-17 16:23pm    
You will never get a Solution if you don't work with us ...
What was wrong with my Solution ...?

Set the SizeMode of each of your Boxex to Zoom
and
at the end of this method insert the command ResumeLayout(True)
and
perhaps it could be useful to send an Invalidate to the Form
 
Share this answer
 
v2
I have seen a similar thing and had no success with various combinations of Suspend/Resume/PerformLayout. Finally I found that adding the pictureboxes to a hidden panel was effective and have had no problems since. I can't offer any explanation for the success of this method so present it as something to try.

C#
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900