Anchor.None doesn’t behave as expected – it should “center align” the control, moving it half the vector of container size change. Tested on Desktop with Panel added to it’s Controls collection.
MSDN – AnchorStyles Enumeration:
(…) If a control has its Anchor property set to AnchorStyles.None, the control moves half of the distance that the container of the control is resized. For example, if a Button has its Anchor property set to AnchorStyles.None and the Form that the control is located on is resized by 20 pixels in either direction, the button will be moved 10 pixels in both directions.
Edit (2016-05-05): Attached simple project I had that issue with. Also, it demonstrates another, minor issue – when i click the “Login” button, the login/password textboxes are moves a pixel up and left, and return to original positions when i release the button.
Thank you Lukasz, It was a problem with the Desktop container. It’s fixed now.
BTW, in your sample the panel ends up to the bottom right (I don’t know if it was intended). That’s because the code sets the size of the Desktop to a small size and sets the Location of the panel to the bottom right. When the layout starts it will maintain the proportions.
Also, I noticed that the initialization code is written by hand in the constructor. It’s a lot better if you move it to InitializeComponent(), put a call in the constructor, and use the designer. Also, when adding controls to a container, it’s better to use SuspendLayout() and ResumeLayout() on the container to prevent the container to perform the layout on every change.
we can’t reproduce. The behavior we see seems to be correct. When Anchor = none the control keeps the same proportional distance, as defined in the msdn specs.
can you please verify again and/or send the test you are using and what is the expected behavior?