tags:

views:

52

answers:

1

Hi,

I currently have all the usual components inside a panel in a form, but how can I have it so when I resize the form it will move the components with it?

I already tried

this.panel1.size = new System.Drawing.Size(this.form.size.width, this.form.size.height);

but it didn't work

+6  A: 

Hi, try setting Anchor or Dock of the panel.The nachor property has 4 possible states Top, Right,Left, Bottom. These states can be combined. IF you set all 4 to panel it wiil resize with the from. Dock is more or less like Anchor jsut experiment with different combinations to see if you can get waht you want. IF what you whant is very complex and can not be done with simple Anchor or Dock you can attach to evnet of the from SizeChanget and calculate the new size of the panel. Best Regards, Iordan

IordanTanev
It was close to working but it wouldn't take up all edges, on selected to adjacent ones. If I do say, Right and Bottom then when I do resize, all content is moving to the bottom right corner.
Sandeep Bansal
Can you give explain waht are you trying to acheave if you want you controls to fill the hole form and when resizing ot stay taht way you have to say Top And Bottom And right And left.
IordanTanev