# Label

URL: https://docs.wisej.com/api/wisej.web/content/wisej.web.label

Version: 4.1
Namespace: **Wisej.Web**

Assembly: **Wisej.Framework** (4.1.0.0)

- Control
- [Label](/api/wisej.web/content/wisej.web.label)
Represents a label control.

- C# - VB.NET

```csharp
public class Label : Control, IButtonControl, IImage, IErrorProvider, ICommandSource
```

```visual
Public Class Label
    Inherits Control
    Implements IButtonControl, IImage, IErrorProvider, ICommandSource
```

## Constructors

### ![Instance member](/img/api/instance.png) Label()

Initializes a new instance of the [Label](/api/wisej.web/content/wisej.web.label) class.

### ![Instance member](/img/api/instance.png) Label(text)

Initializes a new instance of the [Label](/api/wisej.web/content/wisej.web.label) class.

| Name | Type | Description | **text** | [String](https://docs.microsoft.com/dotnet/api/system.string) | Initial text. 

### ![Instance member](/img/api/instance.png) Label(text, location, size)

Initializes a new instance of the [Label](/api/wisej.web/content/wisej.web.label) class.

| Name | Type | Description | **text** | [String](https://docs.microsoft.com/dotnet/api/system.string) | Initial text. | **location** | [Point](https://docs.microsoft.com/dotnet/api/system.drawing.point) | Initial location. | **size** | [Size](https://docs.microsoft.com/dotnet/api/system.drawing.size) | Initial size. 

## Properties

### ![Instance member](/img/api/instance.png) AllowHtml

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean) : Returns or sets a value indicating that the control can display HTML in the Text property. (Default: `False` )

Newlines (CRLF) are converted to <BR/> when [AllowHtml](/api/wisej.web/content/wisej.web.label#allowhtml) is false, or when [AllowHtml](/api/wisej.web/content/wisej.web.label#allowhtml) is true and the text doesn't contain any HTML.

### ![Instance member](/img/api/instance.png) AllowMarkdown

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean) : Returns or sets a value indicating that the control can display markdown text as HTML in the Text property. (Default: `False` )

### ![Instance member](/img/api/instance.png) Anchor

[AnchorStyles](/api/wisej.web/enumerations/wisej.web.anchorstyles) : Returns or sets the edges of the container to which a control is bound and determines how a control is resized with its parent. (Default: `Top, Left` )

### ![Instance member](/img/api/instance.png) AutoEllipsis

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean) : Returns or sets whether the ellipsis character (...) appears at the right edge of the label, denoting that the text extends beyond the size of the label. (Default: `False` )

### ![Instance member](/img/api/instance.png) AutoSize

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean) : Returns or sets a value that indicates whether the control resizes based on its contents. (Default: `False` )

Since 3.5.6Auto sizing behavior in the Label control is slightly different from other controls. When the label is a child of a standard container (i.e. Panel, Form, Page, GroupBox) and it's anchored to the right, auto sizing grows or shrinks the label's width preserving the left position.

When the label is a child of a container with a customLayoutEngine (i.e. FlexLayoutPanel, FlowLayoutPanel, TableLayoutPanel) the auto sizing behavior is the same as all other controls.

You can change the default behavior using the AppContext switch "LabelSelfSize". See [System.AppContext](https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-appcontext) to learn how to set the switch. In code, you can set it in a static Program constructor:

```csharp
class Program {
  static void Program() {
    AppContext.SetSwitch("LabelSelfSize", false);
  }
}
```

### ![Instance member](/img/api/instance.png) AutoToolTip

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean) : Returns or sets whether a tooltip is displayed when the text extends beyond the size of the label. (Default: `False` )

The auto tooltip is set on the browser using the [title](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/title) attribute managed by the browser, does not use the themed tooltip managed by Wisej.NET.

### ![Instance member](/img/api/instance.png) BorderStyle

[BorderStyle](/api/wisej.web/enumerations/wisej.web.borderstyle) : Indicates the border style for the control. (Default: `None` )

### ![Instance member](/img/api/instance.png) CharacterCasing

[CharacterCasing](/api/wisej.web/editors/wisej.web.charactercasing) : Returns or sets the case of the text to display to the user. (Default: `Normal` )

### ![Instance member](/img/api/instance.png) Command

[ICommand](/api/wisej.web/interfaces/wisej.web.icommand) : Returns or sets the [ICommand](/api/wisej.web/interfaces/wisej.web.icommand) implementation to invoke. (Default: `null` )

### ![Protected member](/img/api/protected.png) DefaultSize

[Size](https://docs.microsoft.com/dotnet/api/system.drawing.size) :

### ![Instance member](/img/api/instance.png) DialogResult

[DialogResult](/api/wisej.web/enumerations/wisej.web.dialogresult) : Returns or sets a value that is returned to the parent form when the button is clicked. (Default: `None` )

### ![Instance member](/img/api/instance.png) Dock

[DockStyle](/api/wisej.web/enumerations/wisej.web.dockstyle) : Returns or sets which control borders are docked to its parent control and determines how a control is resized with its parent. (Default: `None` )

### ![Instance member](/img/api/instance.png) EnableNativeContextMenu

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean) : Enables or disables the browser's context menu. (Default: `False` )

### ![Instance member](/img/api/instance.png) Image

[Image](https://docs.microsoft.com/dotnet/api/system.drawing.image) : Returns or sets the image that is displayed on a [Label](/api/wisej.web/content/wisej.web.label) .

### ![Instance member](/img/api/instance.png) ImageAlign

[ContentAlignment](https://docs.microsoft.com/dotnet/api/system.drawing.contentalignment) : Returns or sets the alignment of an image that is displayed in the control. (Default: `MiddleCenter` )

### ![Instance member](/img/api/instance.png) ImageIndex

[Int32](https://docs.microsoft.com/dotnet/api/system.int32) : Returns or sets the image list index value of the image displayed on the label control. (Default: `-1` )

**Throws:**

- [ArgumentOutOfRangeException](https://docs.microsoft.com/dotnet/api/system.argumentoutofrangeexception) The specified index is less than -1.

### ![Instance member](/img/api/instance.png) ImageKey

[String](https://docs.microsoft.com/dotnet/api/system.string) : Returns or sets the key accessor for the image in the [ImageList](/api/wisej.web/buttons/wisej.web.buttonbase#imagelist) . (Default: `""` )

### ![Instance member](/img/api/instance.png) ImageList

ImageList : Returns or sets theImageList that contains the images to display in the [Label](/api/wisej.web/content/wisej.web.label) control. (Default: `null` )

### ![Instance member](/img/api/instance.png) ImageSource

[String](https://docs.microsoft.com/dotnet/api/system.string) : Returns or sets the theme name or URL for the image to display in the [Label](/api/wisej.web/content/wisej.web.label) .

### ![Instance member](/img/api/instance.png) SelfSize

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean) : Returns or sets whether the label resize itself when [AutoSize](/api/wisej.web/content/wisej.web.label#autosize) is true and it's in a container using the default layout engine: i.e.: Panel, Form, Page, GroupBox, UserControl. Since 3.5.6 (Default: `True` )

When self sizing is active (default for standard containers) an auto sizing label will always grow to the right side, even when anchored right, preserving it's left position. This is the default behavior in WinForms applications.

### ![Static member](/img/api/static.png) SelfSizeDefault

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean) : Default value for the [SelfSize](/api/wisej.web/content/wisej.web.label#selfsize) property. Since 3.5.6

The default is true. You can set the value by code or using [AppContext](https://docs.microsoft.com/dotnet/api/system.appcontext) switches: `AppContext.SetSwitch("LabelSelfSize", false);`

### ![Instance member](/img/api/instance.png) Text

[String](https://docs.microsoft.com/dotnet/api/system.string) : Returns or sets the text associated with this control. (Default: `""` )

Newlines (CRLF) are converted to <BR/> when [AllowHtml](/api/wisej.web/content/wisej.web.label#allowhtml) is false, or when [AllowHtml](/api/wisej.web/content/wisej.web.label#allowhtml) is true and the text doesn't contain any HTML.

### ![Instance member](/img/api/instance.png) TextAlign

[ContentAlignment](https://docs.microsoft.com/dotnet/api/system.drawing.contentalignment) : Returns or sets the alignment of text in the label. (Default: `TopLeft` )

### ![Instance member](/img/api/instance.png) UseMnemonic

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean) : Returns or sets whether the first character that is preceded by an ampersand (&) is used as the mnemonic key of the control. (Default: `True` )

## Methods

### ![Protected member](/img/api/protected.png) OnClick(e)

Fires the [Click](/api/wisej.web/general/control/#click) event.

| Parameter | Type | Description | **e** | [EventArgs](https://docs.microsoft.com/dotnet/api/system.eventargs) | An [EventArgs](https://docs.microsoft.com/dotnet/api/system.eventargs) that contains the event data. 

### ![Protected member](/img/api/protected.png) OnCommandChanged(e)

Fires the [CommandChanged](/api/wisej.web/content/wisej.web.label#commandchanged) event.

| Parameter | Type | Description | **e** | [EventArgs](https://docs.microsoft.com/dotnet/api/system.eventargs) | A [EventArgs](https://docs.microsoft.com/dotnet/api/system.eventargs) that contains the event data. 

### ![Protected member](/img/api/protected.png) OnFontChanged(e)

| Parameter | Type | Description | **e** | [EventArgs](https://docs.microsoft.com/dotnet/api/system.eventargs) | 

### ![Protected member](/img/api/protected.png) OnParentChanged(e)

| Parameter | Type | Description | **e** | [EventArgs](https://docs.microsoft.com/dotnet/api/system.eventargs) | 

### ![Protected member](/img/api/protected.png) OnTextChanged(e)

| Parameter | Type | Description | **e** | [EventArgs](https://docs.microsoft.com/dotnet/api/system.eventargs) | 

### ![Protected member](/img/api/protected.png) OnWebEvent(e)

Processes the event from the client.

| Parameter | Type | Description | **e** | WisejEventArgs | Event arguments. 

### ![Protected member](/img/api/protected.png) OnWebRender(config)

Renders the client component.

| Parameter | Type | Description | **config** | [Object](https://docs.microsoft.com/dotnet/api/system.object) | Dynamic configuration object. 

### ![Instance member](/img/api/instance.png) PerformClick()

Generates a [Click](/api/wisej.web/general/control/#click) event for theLinkLabel control.

### ![Protected member](/img/api/protected.png) SetBoundsCore(x, y, width, height, specified)

Sets the specified bounds of the label.

| Parameter | Type | Description | **x** | [Int32](https://docs.microsoft.com/dotnet/api/system.int32) | The new [Left](/api/wisej.web/general/control/#left) property value of the control. | **y** | [Int32](https://docs.microsoft.com/dotnet/api/system.int32) | The new [Top](/api/wisej.web/general/control/#top) property value of the control. | **width** | [Int32](https://docs.microsoft.com/dotnet/api/system.int32) | The new [Width](/api/wisej.web/general/control/#width) property value of the control. | **height** | [Int32](https://docs.microsoft.com/dotnet/api/system.int32) | The new [Height](/api/wisej.web/general/control/#height) property value of the control. | **specified** | [BoundsSpecified](/api/wisej.web/enumerations/wisej.web.boundsspecified) | A bitwise combination of the [BoundsSpecified](/api/wisej.web/enumerations/wisej.web.boundsspecified) values. For any parameter not specified, the current value will be used. 

## Events

### ![Instance member](/img/api/instance.png) CommandChanged

[EventHandler](https://docs.microsoft.com/dotnet/api/system.eventhandler) Fired when the [Command](/api/wisej.web/content/wisej.web.label#command) property value changes.

## Inherited By

| Name | Description | LinkLabel | Represents an hyper-link control. 

## Implements

| Name | Description | [IUserData](/api/wisej.web/interfaces/wisej.web.iuserdata) | Provides access to the `UserData` and `Tag` properties associated to the component implementing this interface. | [IBindableComponent](/api/wisej.web/data-binding/wisej.web.ibindablecomponent) | Bindable components implement this interface. | [IButtonControl](/api/wisej.web/interfaces/wisej.web.ibuttoncontrol) | Allows a control to act like a button on aForm . | [ICommandSource](/api/wisej.web/interfaces/wisej.web.icommandsource) | Defines an object that can invoke a [Command](/api/wisej.web/interfaces/wisej.web.icommandsource#command) . | [IDropTarget](/api/wisej.web/interfaces/wisej.web.idroptarget) | Controls that support drag & drop operations implement this interface. | [IErrorProvider](/api/wisej.web/interfaces/wisej.web.ierrorprovider) | Exposes a common api implemented by components that can collect errors in relation to aControl . | [IImage](/api/wisej.web/interfaces/wisej.web.iimage) | Provides access to common image properties across the controls that implement this interface. | [IWisejComponent](/api/wisej.core/interfaces/wisej.core.iwisejcomponent) | All wisej components implement this interface. | [IWisejControl](/api/wisej.core/interfaces/wisej.core.iwisejcontrol) | All wisej controls derived from theControl class must implement this interface. | [IWisejSerializable](/api/wisej.core/interfaces/wisej.core.iwisejserializable) | Allows an object to serialize itself.
