Panel DockStyle Fill

  • Thread starter Bud J via DotNetMonster.com
  • Start date
B

Bud J via DotNetMonster.com

i have a form with a couple of controls in a couple of different panels with
a dockstyle set to fill and top. if i run this

this.Dock=DockStyle.Fill;
this.Location=new Point(0,0);
this.Show();

in the constructor of the main form as the app is loading all works well

but if i call the same after the main form is loaded the two panels do not
fill they remain in the same position. this seems so simple but it is very
frustrating
 
H

Herfried K. Wagner [MVP]

Bud J via DotNetMonster.com said:
i have a form with a couple of controls in a couple of different panels
with
a dockstyle set to fill and top. if i run this

this.Dock=DockStyle.Fill;
this.Location=new Point(0,0);
this.Show();

in the constructor of the main form as the app is loading all works well

but if i call the same after the main form is loaded the two panels do not
fill they remain in the same position. this seems so simple but it is
very
frustrating

You'll have to set the panels' 'Dock' property instead of the form's 'Dock'
property.
 
B

Bud J via DotNetMonster.com

i set the panel dock property in the InitializeComponent(). are you saying i
need to set it again the contructor
 
B

Bud J via DotNetMonster.com

ok nobody seems to have an answer for this to i'll post more specific detail

the is the contructor for my base form with all mdi children will inherit
from

public frmBase(Form parent)
{
InitializeComponent();
this.MdiParent=parent;
this.parent=parent;

this.Dock=DockStyle.Fill;
this.Location=new Point(0,0);
this.Show();
}


now when the app opens and the parent form

i put this in the contructor of the parent form

Form frm=new frmOne(this); // formOne inherits from the frmBase

frmOne loads perfectly all the panels stretch to their appropriate setting be
it top, bottom fill

however if i put

Form frm=new frmOne(this); // formOne inherits from the frmBase

in something like menu click event the panels don't stretch

any ideas would be greatly appreciated. this seems really simple but without
the panels filling correctly the whole this is worthless
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top