Results 1 to 5 of 5

Thread: Child Control Anchoring and Padding Problem

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2010
    Location
    Huntsville, AL
    Posts
    62

    Child Control Anchoring and Padding Problem

    Hello,

    I've searched in these forums and online, and returned zero results. I'm curious to know if anyone else has experience this problem.

    If you have a Control contained within another Control and the Child Control has the default Anchoring (Top + Left) AND AutoSize=False (Assuming the control has that Property) changing the Parent Control's Top or Left Padding will not offset the Child Control.

    If you change the Anchoring of the Child Control to anything other than the default values OR set AutoSize=True, the Control is correctly offset when the Parent Control's Padding values are changed.

    Is this a bug, or am I missing the reason behind this functionality?

  2. #2
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    Re: Child Control Anchoring and Padding Problem

    EDIT: I must have been half asleep when I posted my advice below, because it doesn't really address the question. Sorry.If you anchor the child control to the top and left, it will stay the same pixel distance from the top and left of the parent. It's size won't change. If you anchor it to bottom and right, it will stay the same distance from the parent's bottom and right.

    If you anchor the child to left and right, it will stretch horizontally to keep the distance from the left and right unchanged. Similarly, if you you anchor it to top and bottom, it will stretch vertically to keep the distances unchanged.

    I hope you can figure out the rest.


    BB

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,274

    Re: Child Control Anchoring and Padding Problem

    Changing Padding and Margin values should not have any immediate impact on any control. Those properties only affect the snapping functionality in the designer, which is only relevant when actually dragging a control. Can you provide a set of steps we can follow to demonstrate this alleged bug?

  4. #4
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    Re: Child Control Anchoring and Padding Problem

    Quote Originally Posted by jmcilhinney View Post
    Changing Padding and Margin values should not have any immediate impact on any control. Those properties only affect the snapping functionality in the designer, which is only relevant when actually dragging a control. Can you provide a set of steps we can follow to demonstrate this alleged bug?
    They are more than a snapping aid. The padding takes effect when you dock a child control into its container. In container controls that perform auto layout, such as a FlowLayoutPanel or Toolstrip, the margins of the child controls are also effective; the margins may overlap the padding of the parent, but not each other. Whether this has any bearing on the OP's question remains to be seen. We don't know what kind of controls he was using.

    BB

  5. #5

    Thread Starter
    Member
    Join Date
    Sep 2010
    Location
    Huntsville, AL
    Posts
    62

    Re: Child Control Anchoring and Padding Problem

    Quote Originally Posted by jmcilhinney View Post
    ...Can you provide a set of steps we can follow to demonstrate this alleged bug?
    The following steps are done within the Designer.
    1. Start with a blank Form or an empty Panel. (I think any container control might yield the same results.)
    2. Add a Label and a Button to the Control from (1).
    3. Leave all of the properties for the Controls set to their default values.
    4. Change either the Top or Left Padding value (or both) for the Control from (1) to 50 (or some other value that would be easy to notice Control repositioning). You should notice that the Label is offset, while the Button is not.
    5. Set all of the Padding values for the Control from (1) back to 0. The Label should return to its original position.
    6. Change the Anchoring property of the Button to anything other than Top + Left.
    7. Change the respective Padding value (Top, Left, etc.) for the Control from (1). Now, both the Button and the Label should be offset.
    8. Set all of the Padding values for the Control from (1) back to 0. Both the Button and the Label should be in their original positions.
    9. Change the Anchoring property of the Button back to Top + Left.
    10. Set the Button's Autosize property to True.
    11. Change any of the Padding values for the Control from (1). Both the Button and the Label should be in their original positions.


    I should point out that the Anchoring values set will affect how the button is offset by the padding. The same rules that govern how the control is repositioned when it's Parent Container is resized are the same with Padding.

    Quote Originally Posted by boops boops View Post
    We don't know what kind of controls he was using.
    I've found that this feature is found in any Controls that have both an Anchoring Property and an Autosize Property.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width