Control Dock question

  • Thread starter Thread starter DBC User
  • Start date Start date
D

DBC User

I am trying to put 2 controls in a page where I want the first control
to have 80% of the screen and the second control 20%. How can I do
that?

I used control property to set the first one to Top and the second one
to Bottom and is not working properly. I am loosing the first controls
bottom portion.

Any help please?

Thanks.
 
DBC User said:
I am trying to put 2 controls in a page where I want the first control
to have 80% of the screen and the second control 20%. How can I do
that?

I used control property to set the first one to Top and the second one
to Bottom and is not working properly. I am loosing the first controls
bottom portion.

Any help please?

One control needs to use DockStyle.Fill

Sample code:

Panel p1 = new Panel();
p1.BackColor = Color.Red;
p1.Width = this.Width / 5;
p1.Dock = DockStyle.Left;
Panel p2 = new Panel();
p2.BackColor = Color.Blue;
p2.Dock = DockStyle.Fill;
this.Controls.Add(p1);
this.Controls.Add(p2);

PS
 
PS said:
One control needs to use DockStyle.Fill

Sample code:

Panel p1 = new Panel();
p1.BackColor = Color.Red;
p1.Width = this.Width / 5;
p1.Dock = DockStyle.Left;
Panel p2 = new Panel();
p2.BackColor = Color.Blue;
p2.Dock = DockStyle.Fill;
this.Controls.Add(p1);
this.Controls.Add(p2);

Add them in the reverse order or add p2.BringToFront() at end. The order in
which you add controls has an effect when one is "Fill".
 
Add them in the reverse order or add p2.BringToFront() at end. The order in
which you add controls has an effect when one is "Fill".






- Show quoted text -- Hide quoted text -

- Show quoted text -

Thanks for the help. Its what I was looking for.
 

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

Back
Top