menu

WinForms

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class Label - WindowsForms API Reference | Syncfusion

    Show / Hide Table of Contents

    Class Label

    A label is a text object that is attached to a container and is positioned relative to some control point on the container.

    Inheritance
    System.Object
    PropertyContainer
    AnchoringPrimitive
    Label
    Implements
    IServiceReferenceHolder
    IServiceReferenceProvider
    IPropertyObserver
    IPropertyContainer
    System.ICloneable
    System.Runtime.Serialization.ISerializable
    System.IDisposable
    Inherited Members
    AnchoringPrimitive.Container
    AnchoringPrimitive.Dispose()
    AnchoringPrimitive.Draw(Graphics)
    AnchoringPrimitive.ID
    AnchoringPrimitive.InvokeUpdateCallback()
    AnchoringPrimitive.OffsetX
    AnchoringPrimitive.OffsetY
    AnchoringPrimitive.OnMeasureUnitsChanging(MeasureUnits, MeasureUnits)
    AnchoringPrimitive.Position
    AnchoringPrimitive.PositionChange(Single, Single)
    AnchoringPrimitive.RecordPropertyChanged(String)
    PropertyContainer.FullContainerName
    PropertyContainer.HistoryService
    PropertyContainer.InheritContainerMeasureUnits
    PropertyContainer.IPropertyObserver.OnPropertyChanged(String, String)
    PropertyContainer.IPropertyObserver.OnPropertyChanging(String, String, Object)
    PropertyContainer.ISerializable.GetObjectData(SerializationInfo, StreamingContext)
    PropertyContainer.m_propertyObserver
    PropertyContainer.MeasureUnit
    PropertyContainer.OnPropertyChanged(String)
    PropertyContainer.OnPropertyChanging(String, Object)
    PropertyContainer.PropertyObserber
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: Syncfusion.Windows.Forms.Diagram
    Assembly: Syncfusion.Diagram.Base.dll
    Syntax
    public class Label : AnchoringPrimitive, IServiceReferenceHolder, IServiceReferenceProvider, IPropertyObserver, IPropertyContainer, ICloneable, ISerializable, IDisposable

    Constructors

    Label()

    Initializes a new instance of the Label class.

    Declaration
    public Label()

    Label(Label)

    Initializes a new instance of the Label class.

    Declaration
    public Label(Label src)
    Parameters
    Type Name Description
    Label src

    The label source.

    Label(Node, String)

    Initializes a new instance of the Label class.

    Declaration
    public Label(Node container, string strText)
    Parameters
    Type Name Description
    Node container

    The container.

    System.String strText

    The label text.

    Label(SerializationInfo, StreamingContext)

    Initializes a new instance of the Label class.

    Declaration
    protected Label(SerializationInfo info, StreamingContext context)
    Parameters
    Type Name Description
    System.Runtime.Serialization.SerializationInfo info

    The info.

    System.Runtime.Serialization.StreamingContext context

    The context.

    Properties

    AdjustRotateAngle

    When set will prevent the label from being inverted.

    Declaration
    public bool AdjustRotateAngle { get; set; }
    Property Value
    Type
    System.Boolean

    BackgroundStyle

    Determines text background style.

    Declaration
    public FillStyle BackgroundStyle { get; }
    Property Value
    Type
    FillStyle

    Constraints

    Gets or Sets the Constraints for the Label

    Declaration
    public LabelConstraints Constraints { get; set; }
    Property Value
    Type
    LabelConstraints

    DirectionRightToLeft

    Gets or sets a value indicating whether the text is right to left.

    Declaration
    public bool DirectionRightToLeft { get; set; }
    Property Value
    Type
    System.Boolean

    DirectionVertical

    Gets or sets a value indicating whether the text is vertical.

    Declaration
    public bool DirectionVertical { get; set; }
    Property Value
    Type
    System.Boolean

    FitBlackBox

    Gets or sets a value indicating whether no part of any glyph overhangs the bounding rectangle.

    Declaration
    public bool FitBlackBox { get; set; }
    Property Value
    Type
    System.Boolean
    Remarks

    By default some glyphs overhang the rectangle slightly where necessary to appear at the edge visually. For example when an italic lowercase letter f in a font such as Garamond is aligned at the far left of a rectangle, the lower part of the f will reach slightly further left than the left edge of the rectangle. Setting this flag will ensure no painting outside the rectangle but will cause the aligned edges of adjacent lines of text to appear uneven.

    FontColorStyle

    Determines font color style.

    Declaration
    public FillStyle FontColorStyle { get; }
    Property Value
    Type
    FillStyle

    FontStyle

    Gets the font style.

    Declaration
    public FontStyle FontStyle { get; }
    Property Value
    Type Description
    FontStyle

    The font style.

    FormatFlags

    Gets flags used to format the text.

    Declaration
    public StringFormatFlags FormatFlags { get; }
    Property Value
    Type
    System.Drawing.StringFormatFlags
    Remarks

    See System.Drawing.StringFormatFlags for more details.

    FullName

    Gets or sets the unique label full name.

    Declaration
    public string FullName { get; }
    Property Value
    Type Description
    System.String

    The unique label full name.

    HorizontalAlignment

    Specifies how an object or text in a control is horizontally aligned relative to an element of the control.

    Declaration
    public StringAlignment HorizontalAlignment { get; set; }
    Property Value
    Type
    System.Drawing.StringAlignment
    Remarks

    This property is used by the GetStringFormat() method to generate a System.Drawing.StringFormat object. This property corresponds to the Alignment property in the System.Drawing.StringFormat class.

    InheritContainerSize

    Gets or sets a value indicating whether current instance inherit container size.

    Declaration
    public bool InheritContainerSize { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if current instance inherit container size; otherwise, false.

    LineLimit

    Gets or sets a value indicating whether only entire lines are laid out in the formatting rectangle.

    Declaration
    public bool LineLimit { get; set; }
    Property Value
    Type
    System.Boolean
    Remarks

    By default, layout continues until the end of the text, or until no more lines are visible as a result of clipping, whichever comes first. Note that the default settings allow the last line to be partially obscured by a formatting rectangle that is not a whole multiple of the line height. To ensure that only whole lines are seen, specify this value and be careful to provide a formatting rectangle at least as tall as the height of one line.

    LineStyle

    Gets the line drawing properties for the label.

    Declaration
    public LineStyle LineStyle { get; }
    Property Value
    Type Description
    LineStyle

    The line style.

    Remarks

    Gets the line style determines the configuration of the pen used to render line. LineStyle

    MeasureTrailingSpaces

    Gets or sets a value indicating whether space at the end of each line in calculations that measure the size of the text.

    Declaration
    public bool MeasureTrailingSpaces { get; set; }
    Property Value
    Type
    System.Boolean
    Remarks

    By default, the boundary rectangle returned by the MeasureString method excludes the space at the end of each line. Set this flag to include that space in measurement.

    Name

    Gets or sets the unique label name.

    Declaration
    public string Name { get; set; }
    Property Value
    Type Description
    System.String

    The unique label name.

    NoClip

    Gets or sets a value indicating whether overhanging parts of glyphs and unwrapped text reaching outside the formatting rectangle are allowed to show.

    Declaration
    public bool NoClip { get; set; }
    Property Value
    Type
    System.Boolean
    Remarks

    By default, all text and glyph parts reaching outside the formatting rectangle are clipped.

    Orientation

    Gets or sets the orientation of label.

    Declaration
    public LabelOrientation Orientation { get; set; }
    Property Value
    Type
    LabelOrientation

    OverflowType

    Gets or sets the Overflow Type

    Declaration
    public OverflowType OverflowType { get; set; }
    Property Value
    Type
    OverflowType

    PropertyBinding

    Binds the text value of the label to a property.

    Declaration
    public LabelPropertyBinding PropertyBinding { get; set; }
    Property Value
    Type
    LabelPropertyBinding
    Remarks

    This property allows the label to be attached to any property of the label. The default binding is to the "Text" property, which is a string property maintained by the label. Setting this property to "ContainerName" will cause the label to display the name of the container (i.e. symbol) that is hosting it.

    ReadOnly

    Flag indicating if the text object is Read-only or not.

    Declaration
    public bool ReadOnly { get; set; }
    Property Value
    Type
    System.Boolean

    RotationAngle

    Gets or sets the rotation angle.

    Declaration
    public float RotationAngle { get; set; }
    Property Value
    Type Description
    System.Single

    The rotation angle in range [ -180; 180 ].

    Remarks

    Rotation angle saved in rotation range [ -180; 180 ] But on set this property new rotation angle must be in range [ 0; 360 ]

    Size

    Gets the label text size.

    Declaration
    public SizeF Size { get; set; }
    Property Value
    Type Description
    System.Drawing.SizeF

    The size.

    SizeToNode

    Gets or Sets Label fit into Parent Node.

    Declaration
    public bool SizeToNode { get; set; }
    Property Value
    Type
    System.Boolean

    Text

    Gets or sets the text.

    Declaration
    public string Text { get; set; }
    Property Value
    Type Description
    System.String

    The text.

    TextCase

    Gets or sets case of text in the label

    Declaration
    public TextCases TextCase { get; set; }
    Property Value
    Type
    TextCases

    TextOverflow

    Gets or sets a value indicating whether overflowing the text.

    Declaration
    public bool TextOverflow { get; set; }
    Property Value
    Type
    System.Boolean

    UpdatePosition

    Gets or Sets whether default positioning has to be used.

    Declaration
    public bool UpdatePosition { get; set; }
    Property Value
    Type
    System.Boolean

    VerticalAlignment

    Gets or sets the vertical alignment of the text.

    Declaration
    public StringAlignment VerticalAlignment { get; set; }
    Property Value
    Type
    System.Drawing.StringAlignment
    Remarks

    This property is used by the GetStringFormat() method to generate a System.Drawing.StringFormat object. This property corresponds to the LineAlignment property in the System.Drawing.StringFormat class.

    Visible

    Specifies visibility of the label.

    Declaration
    public bool Visible { get; set; }
    Property Value
    Type
    System.Boolean

    WrapText

    Gets or sets a value indicating whether text should be wrapped when it exceeds the width of the bounding box.

    Declaration
    public bool WrapText { get; set; }
    Property Value
    Type
    System.Boolean

    Methods

    Clone()

    Creates a new object that is a copy of the current instance.

    Declaration
    public override object Clone()
    Returns
    Type Description
    System.Object

    A new object that is a copy of this instance.

    Overrides
    PropertyContainer.Clone()

    GetLabelBounds()

    Gets the label bounds...

    Declaration
    public RectangleF GetLabelBounds()
    Returns
    Type
    System.Drawing.RectangleF

    GetObjectData(SerializationInfo, StreamingContext)

    Gets the object data to serialize instance.

    Declaration
    protected override void GetObjectData(SerializationInfo info, StreamingContext context)
    Parameters
    Type Name Description
    System.Runtime.Serialization.SerializationInfo info

    The serialization info.

    System.Runtime.Serialization.StreamingContext context

    The serialization context.

    Overrides
    AnchoringPrimitive.GetObjectData(SerializationInfo, StreamingContext)

    GetPosition()

    Positions the Label based on the Position property.

    Declaration
    public override PointF GetPosition()
    Returns
    Type Description
    System.Drawing.PointF

    The new location for the label control

    Overrides
    AnchoringPrimitive.GetPosition()

    GetPropertyContainerByName(String)

    Gets the container of the property by name.

    Declaration
    public override object GetPropertyContainerByName(string strPropertyName)
    Parameters
    Type Name Description
    System.String strPropertyName

    Name of the property.

    Returns
    Type
    System.Object
    Overrides
    PropertyContainer.GetPropertyContainerByName(String)

    GetPropertyContainerName()

    Gets the name of the property container.

    Declaration
    protected override string GetPropertyContainerName()
    Returns
    Type
    System.String
    Overrides
    PropertyContainer.GetPropertyContainerName()

    ProvideServiceReference(RuntimeTypeHandle)

    Get the service reference from provider.

    Declaration
    public override object ProvideServiceReference(RuntimeTypeHandle typeHandle)
    Parameters
    Type Name Description
    System.RuntimeTypeHandle typeHandle

    The Runtime type handle.

    Returns
    Type
    System.Object
    Overrides
    PropertyContainer.ProvideServiceReference(RuntimeTypeHandle)

    Render(Graphics)

    Renders the primitive object to specified graphics.

    Declaration
    protected override void Render(Graphics gfx)
    Parameters
    Type Name Description
    System.Drawing.Graphics gfx

    Graphics to draw on.

    Overrides
    AnchoringPrimitive.Render(Graphics)

    UpdateServiceReferences(IServiceReferenceProvider)

    Updates the service references.

    Declaration
    public override void UpdateServiceReferences(IServiceReferenceProvider provider)
    Parameters
    Type Name Description
    IServiceReferenceProvider provider

    The provider.

    Overrides
    PropertyContainer.UpdateServiceReferences(IServiceReferenceProvider)

    Implements

    IServiceReferenceHolder
    IServiceReferenceProvider
    IPropertyObserver
    IPropertyContainer
    System.ICloneable
    System.Runtime.Serialization.ISerializable
    System.IDisposable
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved