control's Dock property = Fill: fills entire form regardless of other 'Dock's.

Z

Zytan

I just wanted a little practice with the WebBrowser control, so I did
the VB guided tour example here in C#:
http://msdn2.microsoft.com/en-us/library/a08t4ke7(VS.80).aspx
The tutorial asks to put a Panel with a Button and TextBox in it, and
a WebBrowser below it. Then, it sets the Panel's Dock property to be
Top. It sets the WebBroswer's Dock property to be Fill.

But, the WebBrowser then fills the entire form! Even though the
Panel's Dock property is already using the top of the form. I did
this example in VB some time ago, and this did not occur. Is this a
bug? Does C# handle this differently? I would assume Dock implies
like a docking toolbar, no two can occupy the same space.

It takes 1 minute to test this out, so please do if you have time.
You can see the error occurs right within the form designer, before
any code is written.

Zytan
 
R

Rob Whiteside

I just wanted a little practice with the WebBrowser control, so I did
the VB guided tour example here in C#:http://msdn2.microsoft.com/en-us/library/a08t4ke7(VS.80).aspx
The tutorial asks to put a Panel with a Button and TextBox in it, and
a WebBrowser below it. Then, it sets the Panel's Dock property to be
Top. It sets the WebBroswer's Dock property to be Fill.

But, the WebBrowser then fills the entire form! Even though the
Panel's Dock property is already using the top of the form. I did
this example in VB some time ago, and this did not occur. Is this a
bug? Does C# handle this differently? I would assume Dock implies
like a docking toolbar, no two can occupy the same space.

It takes 1 minute to test this out, so please do if you have time.
You can see the error occurs right within the form designer, before
any code is written.

Zytan

Zytan,

I am pretty sure that the "Z" order of the controls determine which
control has priority over the space of your application. Try brining
the Panel to the top, you can right click it in the designer to do
this.

Along similar lines, when you have two items docked to "Top" the Z
order determines which is the topmost.

Cheers,

--Rob W
 
R

Rob Whiteside

Zytan,

I am pretty sure that the "Z" order of the controls determine which
control has priority over the space of your application. Try brining
the Panel to the top, you can right click it in the designer to do
this.

Along similar lines, when you have two items docked to "Top" the Z
order determines which is the topmost.

Cheers,

--Rob W

oops -
By "Bring panel to Top" I meant Bring to _Front_
 
Z

Zytan

I am pretty sure that the "Z" order of the controls determine which
control has priority over the space of your application. Try brining
the Panel to the top, you can right click it in the designer to do
this.

Ah, and I did make the Panel after the WebBrowser (unlike the order of
the tutorial), this is certainly the cause! And it totally makes
sense to have some sense of priority, which needs some kind of
criteria to be based on. And this would be it. Thanks, Rob!

Zytan
 
Z

Zytan

I am pretty sure that the "Z" order of the controls determine which
oops -
By "Bring panel to Top" I meant Bring to _Front_

Changing the tab order doesn't change the Z. I am unsure how to
change the Z. I've tried right clicking and selecting "Bring to
Front" and "Send to Back", but this does nothing, either. I'll mess
some more, and see if I can find the solution (other than recreating
all the controls - there must be a better way).

Zytan
 
Z

Zytan

Changing the tab order doesn't change the Z. I am unsure how to
change the Z. I've tried right clicking and selecting "Bring to
Front" and "Send to Back", but this does nothing, either. I'll mess
some more, and see if I can find the solution (other than recreating
all the controls - there must be a better way).

How to: Define Z-Ordering of Docked ToolStrip Controls
http://msdn2.microsoft.com/en-us/library/ms229673(vs.80).aspx

The z-order is set in the order that you add the controls. So, I'll
have to modify the order of the this.Controls.Add(...); in the
Form1.Designer.cs file. And YES, it works! :)

Zytan
 
R

Rob Whiteside

How to: Define Z-Ordering of Docked ToolStrip Controlshttp://msdn2.microsoft.com/en-us/library/ms229673(vs.80).aspx

The z-order is set in the order that you add the controls. So, I'll
have to modify the order of the this.Controls.Add(...); in the
Form1.Designer.cs file. And YES, it works! :)

Zytan

Instead of modifying the Form1.Designer.cs file, you can right click
on the control in the Designer and choose "Bring to front" or "Send to
back". You can also call those methods programatically
(control.BringToFront();)

--Rob W
 
Z

Zytan

Changing the tab order doesn't change the Z. I am unsure how to
Instead of modifying the Form1.Designer.cs file, you can right click
on the control in the Designer and choose "Bring to front" or "Send to
back". You can also call those methods programatically
(control.BringToFront();)

Yes, as you stated that before, and as you'll see quoted above, I
tried this, and it didn't work.

Although, I agree that it should have. I'll try it again. Strange,
it works now (I can see it modifying the order in the code).

You have to use "Bring to Front" for it to work, which adds the
control FIRST, which makes the other controls, which are added later,
dock first. (I would have thought it would be the other way around -
the first controls added have precedence, but it's not like that.)

I am unsure why your suggestion didn't work the first time. Perhaps
this is why: When changing the z-order, the controls are not
automatically rearranged. To see the results, you need to undock and
then redock. I think when I first tried your suggestion, I was
changing the Dock property, but not to 'none', insteaed to 'bottom',
and this wasn't good enough. You have to change it to 'none', and then
re-dock it to see the proper effect. So, that's a little bug in the
Form Designer.

Thanks again,

Zytan
 

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