Label
Namespace: Wisej.Web
Assembly: Wisej.Framework (4.1.0.0)
Represents a label control.
- C#
- VB.NET
public class Label : Control, IButtonControl, IImage, IErrorProvider, ICommandSource
Public Class Label
Inherits Control
Implements IButtonControl, IImage, IErrorProvider, ICommandSource
Constructors
Label()
Initializes a new instance of the Label class.
Label(text)
Initializes a new instance of the Label class.
| Name | Type | Description |
|---|---|---|
| text | String | Initial text. |
Label(text, location, size)
Initializes a new instance of the Label class.
Properties
AllowHtml
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 is false, or when AllowHtml is true and the text doesn't contain any HTML.
AllowMarkdown
Boolean: Returns or sets a value indicating that the control can display markdown text as HTML in the Text property. (Default: False)
Anchor
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)
Value: A combination of the AnchorStyles values. The default is Top and Left.
AutoEllipsis
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)
Value: true to show the ellipsis; otherwise, false. The default is false.
AutoSize
Boolean: Returns or sets a value that indicates whether the control resizes based on its contents. (Default: False)
Value: true if the control automatically resizes based on its contents; otherwise, false. The default is true.
3.5.6+Auto 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 custom LayoutEngine (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 to learn how to set the switch. In code, you can set it in a static Program constructor:
class Program {
static void Program() {
AppContext.SetSwitch("LabelSelfSize", false);
}
}
AutoToolTip
Boolean: Returns or sets whether a tooltip is displayed when the text extends beyond the size of the label. (Default: False)
Value: true to show the tooltip; otherwise, false. The default is false.
The auto tooltip is set on the browser using the title attribute managed by the browser, does not use the themed tooltip managed by Wisej.NET.
BorderStyle
BorderStyle: Indicates the border style for the control. (Default: None)
Value: One of the BorderStyle values. The default is BorderStyle.None.
CharacterCasing
CharacterCasing: Returns or sets the case of the text to display to the user. (Default: Normal)
Value: One of the CharacterCasing enumeration values that specifies the character case to apply to the text displayed to the user.
Command
ICommand: Returns or sets the ICommand implementation to invoke. (Default: null)
DefaultSize
Size:
Value: The default Size of the control.
DialogResult
DialogResult: Returns or sets a value that is returned to the parent form when the button is clicked. (Default: None)
Value: One of the DialogResult values. The default value is None.
Dock
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)
Value: One of the DockStyle values. The default is None.
EnableNativeContextMenu
Boolean: Enables or disables the browser's context menu. (Default: False)
Image
Image: Returns or sets the image that is displayed on a Label.
Value: An Image displayed on the Label. The default is null.
ImageAlign
ContentAlignment: Returns or sets the alignment of an image that is displayed in the control. (Default: MiddleCenter)
Value: One of the ContentAlignment values. The default is ContentAlignment.MiddleCenter.
ImageIndex
Int32: Returns or sets the image list index value of the image displayed on the label control. (Default: -1)
Value: A zero-based index, which represents the image position in an ImageList. The default is -1.
Throws:
- ArgumentOutOfRangeException The specified index is less than -1.
ImageKey
String: Returns or sets the key accessor for the image in the ImageList. (Default: "")
Value: A string representing the key of the image.
ImageList
ImageList: Returns or sets the ImageList that contains the images to display in the Label control. (Default: null)
Value: An ImageList that stores the collection of Image objects. The default value is null.
ImageSource
String: Returns or sets the theme name or URL for the image to display in the Label.
Value: The theme name or URL for the image to display in the Label.
SelfSize 3.5.6+
Boolean: Returns or sets whether the label resize itself when AutoSize is true and it's in a container using the default layout engine: i.e.: Panel, Form, Page, GroupBox, UserControl.
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.
SelfSizeDefault 3.5.6+
Boolean: Default value for the SelfSize property.
The default is true. You can set the value by code or using AppContext switches: AppContext.SetSwitch("LabelSelfSize", false);
Text
String: Returns or sets the text associated with this control. (Default: "")
Newlines (CRLF) are converted to <BR/> when AllowHtml is false, or when AllowHtml is true and the text doesn't contain any HTML.
TextAlign
ContentAlignment: Returns or sets the alignment of text in the label. (Default: TopLeft)
Value: One of the ContentAlignment values. The default is TopLeft.
UseMnemonic
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)
Value: true if the first character that is preceded by an ampersand (&) is used as the mnemonic key of the control; otherwise, false. The default is true.
Methods
OnClick(e)
Fires the Click event.
OnCommandChanged(e)
Fires the CommandChanged event.
OnFontChanged(e)
Fires the FontChanged event.
OnParentChanged(e)
Fires the ParentChanged event.
OnTextChanged(e)
Fires the TextChanged event.
OnWebEvent(e)
Processes the event from the client.
| Parameter | Type | Description |
|---|---|---|
| e | WisejEventArgs | Event arguments. |
OnWebRender(config)
Renders the client component.
| Parameter | Type | Description |
|---|---|---|
| config | Object | Dynamic configuration object. |
PerformClick()
Generates a Click event for the LinkLabel control.
SetBoundsCore(x, y, width, height, specified)
Sets the specified bounds of the label.
| Parameter | Type | Description |
|---|---|---|
| x | Int32 | The new Left property value of the control. |
| y | Int32 | The new Top property value of the control. |
| width | Int32 | The new Width property value of the control. |
| height | Int32 | The new Height property value of the control. |
| specified | BoundsSpecified | A bitwise combination of the BoundsSpecified values. For any parameter not specified, the current value will be used. |
Events
CommandChanged
EventHandler Fired when the Command property value changes.
Inherited By
| Name | Description |
|---|---|
| LinkLabel | Represents an hyper-link control. |
Implements
| Name | Description |
|---|---|
| IUserData | Provides access to the UserData and Tag properties associated to the component implementing this interface. |
| IBindableComponent | Bindable components implement this interface. |
| IButtonControl | Allows a control to act like a button on a Form. |
| ICommandSource | Defines an object that can invoke a Command. |
| IDropTarget | Controls that support drag & drop operations implement this interface. |
| IErrorProvider | Exposes a common api implemented by components that can collect errors in relation to a Control. |
| IImage | Provides access to common image properties across the controls that implement this interface. |
| IWisejComponent | All wisej components implement this interface. |
| IWisejControl | All wisej controls derived from the Control class must implement this interface. |
| IWisejSerializable | Allows an object to serialize itself. |