With An anchor I can write the following line:
myControl.Anchor = (AnchorStyles.Top | AnchorStyles.Left);
And it will anchor myControl
to the left and the top.
Why can't I do the following:
myControl.Dock = (DockStyle.Top | DockStyle.Left);
I can write the above line, but all it does is set the DockStyle
to left.
Any thoughts/reasons for this?
The reason you cannot do this is because setting a DockStyle
basically docks/fills the entirity of the specified edge.
For example, DockStyle.Left
means that the height of the item being docked will always be the height of the container and the the X,Y location will always be 0, 0.
DockStyle.Top
means that the width of the item will always be the width of the container and the location will always be 0,0.
Setting DockStyle.Top
and DockStyle.Left
would essentially give you DockStyle.Fill
. I.e. the same width and height as the container.