Welcome to WindowsClient.net | Sign in | Join

Here are some frequently asked questions about Windows Forms and their answers.

Windows Forms FAQs

Browse by Tags

All Tags » Layout (Docking and Anchoring) (RSS)


  • What are some things that affect Layout performance?

    The section lists out common performance problems and suggested solutions. Changing the UI in OnLoad Problem : Changing properties such as Bounds, Size, Location, Visible and Text/Image/etc for AutoSized controls InitializeComponent and/or Suspend/ResumeLayout...
  • What properties/methods cause layout?

    This lists contains all the "reasons" for layout we pass to the LayoutEventArgs. Usually the strings correspond to the properties. Alignment ColumnStyles ImageIndex Orientation ShowImageMargin Anchor Controls ImageScaling PreferredSize ShowCheckMargin...
  • How do SuspendLayout and ResumeLayout work?

    SuspendLayout and ResumeLayout only prevent OnLayout from being called. Additionally they only prevent OnLayout from being called for that particular control. So if you have a Form with a Panel in it, and call SuspendLayout on the Form, the Panel's...
  • How can I diagnose a performance problem with Layout?

    In the UI that you believe to be laying out the most, either override OnLayout or sync the Layout event. In the event use Debug WriteLines to write both the current size of the control and the call stack of how we got here. You can also print out the...
  • What are Padding & Margin?

    Padding is the internal space you can add to your control/item Margin is the external space you can add to separate controls/items. Depending on the implementation of GetPreferredSize for a control, changing the Padding property can inflate the control...
  • What happens when I have Dock and Anchors that conflict?

    The simple answer is this is not possible. When you set an anchor, the dock style clears. And vise versa if you set the dock style. Under the covers, we use the same bit fields to represent dock and anchor, so it is not possible to get into a conflicting...
  • What are Docking & Anchor?

    Dock and anchor concepts apply to the default layout used for Forms. Simply put, anchor maintains the distance between the edge of the control and the corresponding edge of the container in which it is anchored. By default, controls are anchored top left...
  • How do I prevent a control from being resized manually by the user or through docking or anchoring?

    The best way to ensure a particular height or width for a control is to override the control's SetBoundsCore method. This sample shows a Button which has a fixed height and width. The same technique can be used to set upper- and lower-bounds on sizes...
  • How do I create a custom layout engine?

    Chris Anderson discusses how to implement a custom layout engine and gives sample code in the article Providing Custom Layout Engines for Windows Forms (also available here ). Contributed from George Shepherd's Windows Forms FAQ


Page view counter