dotnetmonitor.com

 
Index
Previous
Next

 

Assortment of layout related terms.

  • AutoLayout - a foofy term used to describe the set of whidbey features which aid in localization of UI.
  • A UI that exhibits AutoLayout does not require localizers to move the locations of controls after they have updated the text in a new language. This generally implies usage of AutoSize on controls, and usage of FlowLayoutPanel and TableLayoutPanel - although there are certain cases where this is not necessary. If the text of the control can grow by ~30% without clipping, you do not need to do anything special.
  • AutoScale - a feature which (in V1 AutoScaleBaseSize, in V2 in AutoScaleDimensions) which grows/shrinks and shifts controls by a scaling factor when the font has changed for the form. (e.g. when customer switches DPI or moves to large fonts). This is the managed solution for dialog units.
  • AutoSize - a boolean flag on control which automatically forces the size of the control to be the "preferred size" as specified by the protected virtual GetPreferredSize method.
  • Bounds represents the total size of the control and the location of the control with respect to the controls parent. In the case where the control does not have a parent, (usually a form), the location represents the location on the screen.
  • ClientRectangle represents the size of the control without the non-client border elements such as scrollbars, title bars, menus, and window borders. Since this rectangle is represented in the client coordinate system, by definition, the value returned by the ClientRectangle.Location will always be (0,0).
  • ClientSize returns/sets ClientRectangle.Size.
  • DisplayRectangle: the area in which to layout, which is also used in scrolling. This rectangle should be used as the frame of reference to layout child controls. Normally, the display rectangle is the same as the client rectangle. However for controls deriving from ScrollableControl, this rectangle can be larger than the client area. Unlike the ClientRectangle, the origin of the DisplayRectangle.Location property can be negative, representing how much the window is currently scrolled. The location of the DisplayRectangle corresponds to the AutoScrollPosition property of a ScrollableControl.

    In order to have proper scrolling support, is important to respect the location of the display rectangle when setting the bounds of a child control.

    E.g. Button1.Location = new Point(this.DisplayRectangle.Location.X + 20, this.DisplayRectangle.Location.Y + 20);
  • FlowLayoutPanel - a panel which lays out its child controls in a flowing manner. Different flow directions, wrapping, and flow breaks are supported.
  • GetPreferredSize - a method which controls override to specify how big they want to be. Containers/panels usually measure all their children, children usually measure their visual elements (text, image) and report back their suggested size.
  • Location returns/sets Bounds.Location
  • MinimumSize: The smallest Size a control is allowed to become.
  • MaximumSize: The largest Size a control is allowed to become.
  • PreferredSize: This generally returns the ideal size for the control to show its contents correctly. This is implemented by calling GetPreferredSize(0,0).
  • RightToLeftLayout - a flag that controls whether the control layout is right-to-left or left-to-right when RightToLeft==Yes (uses WS_EX_LAYOUTRTL mirroring).
  • Size returns/sets Bounds.Size
  • TableLayoutPanel - a panel which lays out its child controls according to rows and columns. Row and column styles, row spanning and column spanning are supported
Docking Anchor Layout
What happens when I have Dock and Anchors that conflict?
Dock Scenarios
Padding Margin
You have a perf problem with Layout - how to diagnose?