This topic has not yet been rated - Rate this topic

SnapLine Class

Represents the horizontal and vertical line segments that are dynamically created in the user interface (UI) to assist in the design-time layout of controls in a container. This class cannot be inherited.

System.Object
  System.Windows.Forms.Design.Behavior.SnapLine

Namespace:  System.Windows.Forms.Design.Behavior
Assembly:  System.Design (in System.Design.dll)
public sealed class SnapLine

The SnapLine type exposes the following members.

  Name Description
Public method SnapLine(SnapLineType, Int32) Initializes a new instance of the SnapLine class using the specified snapline type and offset.
Public method SnapLine(SnapLineType, Int32, String) Initializes a new instance of the SnapLine class using the specified snapline type, offset, and filter name.
Public method SnapLine(SnapLineType, Int32, SnapLinePriority) Initializes a new instance of the SnapLine class using the specified snapline type, offset, and priority.
Public method SnapLine(SnapLineType, Int32, String, SnapLinePriority) Initializes a new instance of the SnapLine class using the specified snapline type, offset, filter name, and priority.
Top
  Name Description
Public property Filter Gets the programmer-defined filter category associated with this snapline.
Public property IsHorizontal Gets a value indicating whether the snapline has a horizontal orientation.
Public property IsVertical Gets a value indicating whether the snapline has a vertical orientation.
Public property Offset Gets the number of pixels that the snapline is offset from the origin of the associated control.
Public property Priority Gets a value indicating the relative importance of the snapline.
Public property SnapLineType Gets the type of a snapline, which indicates the general location and orientation.
Top
  Name Description
Public method AdjustOffset Adjusts the Offset property of the snapline.
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method Static member ShouldSnap Returns a value indicating whether the specified SnapLine should snap to another SnapLine.
Public method ToString Returns a string representation of the current snapline. (Overrides Object.ToString().)
Top

The following table lists the common modes that visual design tools support to assist you with positioning and sizing controls on a design surface.

Mode

Description

Freeform

Enables you to freely lay out controls.

Grid

Displays a static overlaid grid that assists you in laying out controls.

Snapline

Displays guide lines that assist you in laying out the container's controls relative to each other. Snaplines originate from controls and their container.

The SnapLine class and related types help support the Snapline mode.

Snaplines are generated dynamically and automatically as a control edge moves near another control or near the boundaries of its container. This can occur when a control is added from the toolbox, or moved or resized by mouse operations or keyboard commands. Controls typically have both horizontal and vertical snaplines defined; for rectangular controls, these typically extend from all four edges.

The SnapLine class uses only a few properties to describe each snapline, as shown in the following table.

Property

Description

SnapLineType

Specifies the location and direction of the line with respect to its associated control. Typically, only snaplines of similar types will auto-align to each other.

Offset

Specifies the distance in pixels from the origin, which is the upper-left corner of the control, to where the snapline starts.

Priority

Specifies the relative importance of the snapline. During any given layout decision point, only the snaplines that are active and have the highest priority are displayed.

Filter

Defines custom categories of snaplines. This is an optional string.

IsHorizontal and IsVertical

Indicates whether a snapline has horizontal or vertical orientation, respectively.

The ControlDesigner class stores snaplines for its corresponding control type in the SnapLines property. This base class handling of snaplines will suffice for the majority of controls, as it defines the Left, Right, Top, and Bottom snaplines, which are aligned along the edges of the control. When you are developing a custom control, if this default organization does not suffice, override the SnapLines property of the class derived from ControlDesigner. For example, you may want to align the horizontal snaplines of text-based controls, such as labels, with the top and base lines of the text (instead of the top and bottom edges of the control).

The SnapLineType class cannot be derived from.

There is extensive support for this feature in Visual Studio.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ