PDA

View Full Version : DockStyle.Fill ignoring Location


e-x
03-17-2012, 06:32 AM
Does setting a control's DockStyle to Fill ignore its Location?

Image of said problem:
http://i.imgur.com/IZTX3.jpg

The red panel shouldn't be behind the green one. I would think it's Location property should but it below the green panel, unless I'm missing something.

And my code:
mainWin = dotNetObject "MaxCustomControls.MaxForm"
mainWin.size = dotNetObject "System.Drawing.Size" 300 200

p1 = dotNetObject "Panel"
p2.Dock = (dotNetClass "System.Windows.Forms.DockStyle").Top
p1.BackColor = p1.BackColor.fromARGB 0 200 0
p1.size = dotNetObject "System.Drawing.Size" 150 24

p2 = dotNetObject "Panel"
p2.Location = dotNetObject "System.Drawing.Point" 0 24
p2.Dock = (dotNetClass "System.Windows.Forms.DockStyle").Fill
p2.BackColor = p2.BackColor.fromARGB 200 0 0
p2.BorderStyle = p2.BorderStyle.FixedSingle

mainWin.controls.add p1
mainWin.controls.add p2

mainWin.showmodeless()

Gravey
03-17-2012, 07:57 AM
fill means set the control's size and location to fit exactly into it's parent's ClientRectangle, so yes it does 'ignore' the location property in this case. if you want to align only the left, right and bottom edges you should be able to use dotnet.combineEnums to get the required dockstyle

e-x
03-17-2012, 03:43 PM
fill means set the control's size and location to fit exactly into it's parent's ClientRectangle, so yes it does 'ignore' the location property in this case. if you want to align only the left, right and bottom edges you should be able to use dotnet.combineEnums to get the required dockstyle

Not sure you can combine DockStyle enums. Combining Anchor enums works though, and that seems to have fixed my problem. I have to set the Anchor to all sides and make sure the red panel is the same size as my form, minus the size of the green panel. It will then behave exactly as if it's been fill docked.

Thanks for the help.

denisT
03-17-2012, 10:12 PM
Does setting a control's DockStyle to Fill ignore its Location?

...
The red panel shouldn't be behind the green one. I would think it's Location property should but it below the green panel, unless I'm missing something.

And my code:

p1 = dotNetObject "Panel"
p2.Dock = (dotNetClass "System.Windows.Forms.DockStyle").Top
...
mainWin.controls.add p1
mainWin.controls.add p2
...

first of all you have to fix a bug, and second change the order how you add controls to:

mainWin.controls.addrange #(p2, p1)

that solves a problem.

e-x
03-17-2012, 11:01 PM
first of all you have to fix a bug

Well that's embarrassing...

Thanks for the help, appreciated as always.

CGTalk Moderation
03-17-2012, 11:01 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.