Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am putting one TextBox and one Button control(just for testing) at the left corner of the windows form and a PictureBox control and puttng a image into it so,my requirement is whenever i will increase the form size the PictureBox control need to be maximize.I know about the Dock and Anchor property so can anyone help me out.
Posted

Set the Anchor properties to all four sides - that way the PictureBox will remain the same distance from all sides as the form grows and shrinks - you know that already.

If what you want is the Image in the PictureBox to also grow and shrink, then just set the PictureBox.SizeMode to StretchImage
 
Share this answer
 
Comments
Prafulla Sahu 21-Mar-12 7:50am    
Thank u,thank u,thank u alot
OriginalGriff 21-Mar-12 7:55am    
You're welcome!
Do you want PictureBox to maximize and re-render the image? This simple functionality is already questionable in terms of the abuse of this component which is designed to be used only in the simplest situations, but very easily. Should you do something a bit more complex than just showing one static picture (well, maybe changing the picture occasionally, but not often), this component provides no help but just obstacles; it eats up development time and extra resources, offering no useful functionality in return.

Abuse of this control type is very usual and regularly causes big deal of frustration.

No useful compared with what? Compared to a simple custom control derived from System.Windows.Forms.Control handling the event Paint or overriding the virtual method Paint. If you do anything to the image, this is the most adequate technique.

For further detail, please see my past answers:
How do I clear a panel from old drawing[^],
draw a rectangle in C#[^].

See also these answers for better understanding of the technique:
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[^],
Drawing Lines between mdi child forms[^].

—SA
 
Share this answer
 
v2

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