Table of Contents

Class Label

Namespace
Alternet.UI
Assembly
Alternet.UI.dll

Represents a text label control.

[DefaultBindingProperty("Text")]
[ControlCategory("Common")]
public class Label : Control, IBaseObject, IDisposableObject, IInputElement, ISupportInitialize, IFocusable, IWin32Window, ITextProperty, IComponent, IDisposable
Inheritance
Label
Implements
Extension Methods

Examples

Here is how to declare a Label in UIXML:

<Border>
  <Label Name="label" Text="Sample Label" Margin="8" TextChanged="Label_TextChanged"/>
</Border>

And the corresponding event handler in the code-behind:

private void Label_TextChanged(object? sender, EventArgs e)
{
    var text = label.Text == "" ? "\"\"" : label.Text;
    MessageBox.Show(text, string.Empty);
}

Also, a Label can be created from code:

var Label = new Alternet.UI.Label();

Remarks

Label controls are typically used to provide descriptive text for a control. For example, you can use a Label to add descriptive text for a TextBox control to inform the user about the type of data expected in the control. Label controls can also be used to add descriptive text to a Window to provide the user with helpful information. For example, you can add a Label to the top of a Window that provides instructions to the user on how to input data in the controls on the form. Label controls can also be used to display run time information on the status of an application. For example, you can add a Label control to a form to display the status of each file as a list of files is processed.

Examples of how a Label can look on different platforms:

Set Text property to specify the text displayed on the control. A Label, like any other Control, can be disabled by setting its Enabled property to false.

Constructors

Label()

Initializes a new instance of the Label class.

Label(string)

Initializes a new instance of the Label class with specified text.

Properties

ControlKind

Returns control identifier.

Text

Gets or sets the text associated with this control.

Methods

Wrap(double?)

Wraps Text so that each of its lines becomes at most width pixels wide if possible (the lines are broken at words boundaries so it might not be the case if words are too long).