Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Collapse]Form Layout Managers
    Side Panel
   [Collapse]Layout Manager
    [Expand]Product Information
    [Expand]Getting Started
    [Expand]Layout Control
    [Expand]Data Layout Control
    [Expand]Layout Item
    [Expand]Layout Groups
    [Expand]Tabbed Group
    [Expand]Other Layout Elements
    [Expand]Customization Capabilities
    [Expand]Size and Alignment
     Flow Layout
     Table Layout
     Focus Management
    [Expand]Appearance and Look and Feel
    [Expand]Miscellaneous
    [Collapse]Examples
      How to: Access an item located at a specific point
      How to: Add new menu item to the Layout Tree View Context Menu
      How to: Create a tabbed group in code
      How to: Create custom customization form
      How to: Create custom 'fixed' item
      How to: Create layout groups and items in code
      How to: Create layout items in code
      How to: Custom align a control within its layout item
      How to: Enable the Auto-Size Feature for a CheckEdit and Align It Horizontally
      How to: Implement custom functionality for layout context menu
      How to: Lock the size of a layout item
      How to: Make a LayoutControl transparent
      How to: Print a LayoutControl and show its print preview
      How to: Provide Size Constraints for Control via IXtraResizable Interface
      How to: Save and restore layout
      How to: Save the layout between application runs
      How to: Specify which properties to display in the Property Grid when selecting layout items
      How to: Update a Layout Item and its Control
    [Expand]Member Tables
   [Expand]Tabbed MDI Manager
    Tab Control
   [Expand]Wizard Control
    Workspace Manager
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

How to: Lock the size of a layout item

When the Layout Control is resized all its layout items are resized proportionally (the size constraints are taken into account). There are many cases when you need to lock the size of a layout item, so that it's not resized when the Layout Control is resized. To do so, you need to:

  1. set the layout item's MaxSize property to the required size that the item must have;
  2. set the layout item's MinSize property to the same value as the MaxSize property.

Now the layout item's size is locked. Again, alternatively you can use the ControlMinSize and ControlMaxSize properties.

To lock the layout item's height, but still allow the item's width to be freely changed, do the following:

set the item's MaxSize.Height and then the MinSize.Height properties to the required height; set the item's MaxSize.Width and MinSize.Width properties to 0.

To allow the layout item's height to be freely changed set the MaxSize.Height and MinSize.Height properties to 0.

Expanded Example

This example shows how to lock the size of a layout item at design time and runtime.

Assume that a layout control is docked to the form so that it fills this form. It contains three layout items: 1) the item that displays a MemoEdit control; 2) an Empty Space Items and 3) the item that contains a button:

When the form is resized, all the items are resized proportionally:

It would be better to prevent the layout item that contains the button from being resized. To perform this at design time, you can use the Context Menu provided by the Layout Control. Also see the Custom Size Constraints topic for information on the menu's commands related to imposing size constraints on layout items.

Expanded Design-Time Example

To lock the item's size do the following:

  1. Apply the Free Sizing command to the layout item that contains the button:

  2. Resize this layout item on the form, so that it takes the required size

  3. Apply the Lock Size command to this item:

Now when the form is resized the button retains its original size:

Note that the Size Constraints menu is also available at runtime in customization mode. To invoke this mode at runtime an end-user can activate the Customization Form.

Expanded Runtime Example

To lock the size of a layout item in code, set the LayoutControlItem.SizeConstraintsType to Custom and then set the layout item's LayoutControlItem.MaxSize and LayoutControlItem.MinSize properties to the required size. The following code is equivalent to the design-time sample shown above:

Expanded See Also

How would you rate this topic?​​​​​​​