I am trying to display images in a Panel control (I am using WinForms), however the images are bigger than the panel's maximum size (32767 pixels).
I searched the Internet about the issue, however I only found a few ready solutions I do not understand, therefore do not want to use them.
What and is there a good way around this issue aside from using WPF?
As of now, I am thinking of manually iterating over controls in Panel and changing their location as needed, however, I think it will not be very efficient and ugly.
Sample code to reproduce the problem:
for (int i = 0; i < 300; i++) {
PictureBox picbox = new PictureBox();
picbox.BackColor = Color.Red;
picbox.Width = 500;
picbox.Height = 250;
picbox.Top = i * 500;
panelDisplay.Controls.Add(picbox);
}
Sounds to me like you might try using more than a single panel.
Very roughly:
// (5 of these) x (60 pictureboxes in each) = 300 images in all:
for (int panelNumber = 0; panelNumber < 5; panelNumber++) {
Panel panel = new Panel();
panel.Height = 30000;
panel.Top = panelNumber * 30000;
// ...anything else needed to set up the panel...
for (int PictureBoxNr = 0; PictureBoxNr< 60; PictureBoxNr++) {
PictureBox picbox = new PictureBox();
picbox.BackColor = Color.Red;
picbox.Width = 500;
picbox.Height = 250;
picbox.Top = PictureBoxNr * 500;
panel.Controls.Add(picbox);
}
outerPanel.Controls.Add(panel);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.