Click here to Skip to main content
15,947,389 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I have a Windos Form, then a TabPanel, then a Panel and inside that panel I have multiple pictureboxes. How can I resize the pictureboxes so they adapt when I resize the window?

Thanks a lot

I assume this is a Windows app? The Anchor properties of the controls determine how they behave when the form is resized. Just play with those in the Properties window and try it until you get the behavior you want.
Share this answer
If you are talking about automatic resize of any control, you can usually have it docked to some other control like Panel (or a Form, TabPage and others) which itself would be resized. You need to use Dock property with the value System.Windows.Forms.DockStyle.Fill:[^],[^].

Anchors would work, too, but usually Dock with Padding is much better. See also:[^].

However, I don't sure that you really need to resize PictureBox. Most likely, you should not use this control at all. It is totally redundant (you can implement it using the same API) and only needed to simplify the simplest chores (static image of fixed size and so on). It becomes a hassle when you try to do anything even a tiny bit more complex. In your case, the problem would be resampling of the image.

(By the way, you should understand that resampling an image up its quality unacceptable. You can only make it smaller than original, or only slightly bigger. unless you agree to make it ugly looking.)

So, not using PictureBox could be better than using it. Please see my past answers:
Append a picture within picturebox[^],
draw a rectangle in C#[^],
How do I clear a panel from old drawing[^].

And also:
capture the drawing on a panel[^],
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[^],
How to speed up my application?[^],
Drawing Lines between mdi child forms[^].

I hope it will explain the simple techniques you need to understand.

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