Class AutoLabel
Represents a AutoLabel control with advanced customization options on background, text, and border etc.
Inheritance
Namespace: Syncfusion.Windows.Forms.Tools
Assembly: Syncfusion.Shared.Base.dll
Syntax
public class AutoLabel : Label, IThemeProvider, IVisualStyle
Remarks
Once a control is labeled by an instance of AutoLabel (through the LabeledControl property, the label gets moved around as the labeled control moves around automatically, preserving the relative positions. The relative positions can also be configured to be left, top or custom through the Position property.
Note that the FlowLayout manager will treat the label and its control as a pair, always laying them out together as if they were one single control.
Examples
using System.Windows.Forms;
namespace AutoLabel
{
public partial class Form1 : Form
{
private Syncfusion.Windows.Forms.Tools.AutoLabel autoLabel1;
public Form1()
{
InitializeComponent();
//Initialization
this.autoLabel1 = new Syncfusion.Windows.Forms.Tools.AutoLabel();
//Set the properties
this.autoLabel1.Text = "autoLabel1";
this.autoLabel1.BackColor = System.Drawing.Color.DarkGray;
this.autoLabel1.ForeColor = System.Drawing.Color.DarkBlue;
this.autoLabel1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.autoLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
// Add the AutoLabel control to the form.
this.Controls.Add(this.autoLabel1);
}
}
}
Constructors
AutoLabel()
Initializes a new instance of the AutoLabel class.
Declaration
public AutoLabel()
Properties
AutoSize
Gets or sets a value indicating whether the control is automatically resized to display its entire contents.
Declaration
public override bool AutoSize { get; set; }
Property Value
Type |
---|
System.Boolean |
See Also
CanApplyTheme
Gets or sets a value indicating whether a SkinManager ThemeStyle. has been applied to the control.
Declaration
public bool CanApplyTheme { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | The default value is true. |
See Also
CanOverrideStyle
Gets or sets a value indicating whether control elements styles can be overridden by ThemeStyle settings.
Declaration
public bool CanOverrideStyle { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | Default value is false. |
Remarks
By default, the control's element styles will not be overridden by ThemeStyle settings if the style is set in sample level. If this property is enabled, element style will be overridden by ThemeStyle settings event if it is set in sample level. This property should be enabled or disabled before calling the ThemeName property of the control.
See Also
DX
Gets or sets the effective horizontal distance between the left of the AutoLabel and its labeled control.
Declaration
public int DX { get; set; }
Property Value
Type |
---|
System.Int32 |
Remarks
When System.Windows.Forms.RightToLeft == System.Windows.Forms.RightToLeft.Yes DX is the distance between the right of the labeled control and the right of the AutoLabel.
See Also
DY
Gets or sets the effective vertical distance between the top of the AutoLabel and its labeled control.
Declaration
public int DY { get; set; }
Property Value
Type |
---|
System.Int32 |
See Also
Enabled
Gets or sets the AutoLabel control is enabled.
Declaration
public bool Enabled { get; set; }
Property Value
Type |
---|
System.Boolean |
See Also
Font
Declaration
public override Font Font { get; set; }
Property Value
Type |
---|
System.Drawing.Font |
Gap
Gets or sets the horizontal and vertical gap to use when computing the relative position.
Declaration
public int Gap { get; set; }
Property Value
Type |
---|
System.Int32 |
See Also
IsVisualStyleEnabled
Gets a value indicating whether the visual style based theme is applied to the control and also indicates whether the theme files are referred from external assemblies or not.
Declaration
public bool IsVisualStyleEnabled { get; }
Property Value
Type | Description |
---|---|
System.Boolean | Return true, if the visual style based theme is applied to the control. Otherwise returns false. |
See Also
LabeledControl
Gets or sets the control that is being labeled.
Declaration
public Control LabeledControl { get; set; }
Property Value
Type | Description |
---|---|
System.Windows.Forms.Control | A control instance. |
Position
Gets or sets the relative position of the control and the AutoLabel.
Declaration
public AutoLabelPosition Position { get; set; }
Property Value
Type |
---|
AutoLabelPosition |
See Also
PreferredHeight
Declaration
public override int PreferredHeight { get; }
Property Value
Type |
---|
System.Int32 |
Style
Gets or sets the VisualStyle to the AutoLabel.
Declaration
public AutoLabelStyle Style { get; set; }
Property Value
Type |
---|
AutoLabelStyle |
See Also
ThemeName
Gets or sets the theme name of the AutoLabel control.
Declaration
public string ThemeName { get; set; }
Property Value
Type |
---|
System.String |
ThemeStyle
Gets or sets the AutoLabelVisualStyle value used to customize the appearance of the
Declaration
public AutoLabelVisualStyle ThemeStyle { get; set; }
Property Value
Type |
---|
AutoLabelVisualStyle |
Remarks
This ThemeStyle settings will be applied only when the VisualStyleBased theme has been applied to the control.
Methods
Dispose(Boolean)
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing |
GetActiveThemeName()
Gets the active theme name of the AutoLabel control.
Declaration
public string GetActiveThemeName()
Returns
Type | Description |
---|---|
System.String | Returns the active theme name. |
OnAttachLabeledControl(Control)
Called when a new control is getting labeled (when set through the LabeledControl property.
Declaration
protected virtual void OnAttachLabeledControl(Control labeledControl)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Forms.Control | labeledControl | The control that is being labeled. |
OnDetachLabeledControl(Control)
Called when an exisiting label is getting unlabeled.
Declaration
protected virtual void OnDetachLabeledControl(Control labeledControl)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Forms.Control | labeledControl | The control that is being unlabeled. |
OnFontChanged(EventArgs)
Font changed
Declaration
protected override void OnFontChanged(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e |
OnLocationChanged(EventArgs)
Declaration
protected override void OnLocationChanged(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e |
OnParentRightToLeftChanged(EventArgs)
Declaration
protected override void OnParentRightToLeftChanged(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e |
OnPropertyChanged(SyncfusionPropertyChangedEventArgs)
Raises the PropertyChanged event.
Declaration
protected virtual void OnPropertyChanged(SyncfusionPropertyChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
SyncfusionPropertyChangedEventArgs | e | An System.EventArgs object containing data pertaining to this event. |
Remarks
The OnPropertyChanged method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
Note to Inheritors: When overriding OnPropertyChanged in a derived class, be sure to call the base class's OnPropertyChanged method so that registered delegates receive the event.
OnRightToLeftChanged(EventArgs)
Declaration
protected override void OnRightToLeftChanged(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e |
OnSizeChanged(EventArgs)
Declaration
protected override void OnSizeChanged(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e |
SetBoundsCore(Int32, Int32, Int32, Int32, BoundsSpecified)
Sets the specified bounds of the label.
Declaration
protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | |
System.Int32 | y | |
System.Int32 | width | |
System.Int32 | height | |
System.Windows.Forms.BoundsSpecified | specified |
UpdatePosition()
Updates the position of the AutoLabel when the parameters that affect the relative positions have changed (like the LabeledControl's position, size, etc.).
Declaration
protected virtual void UpdatePosition()
WndProc(ref Message)
Processes Windows messages.
Declaration
protected override void WndProc(ref Message m)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Forms.Message | m | The Windows System.Windows.Forms.Message to process. |
Events
PropertyChanged
Fired when the LabeledControl Control, Gap and Position properties of this class changes.
Declaration
public event SyncfusionPropertyChangedEventHandler PropertyChanged
Event Type
Type |
---|
SyncfusionPropertyChangedEventHandler |
ThemeNameChanged
Occurs when theme name of the AutoLabel has changed.
Declaration
public event ThemeChangedEventHandler ThemeNameChanged
Event Type
Type |
---|
ThemeChangedEventHandler |
Explicit Interface Implementations
IVisualStyle.VisualTheme
Declaration
string IVisualStyle.VisualTheme { get; set; }
Returns
Type |
---|
System.String |
IThemeProvider.BaseThemeName
Gets or sets the BaseTheme name of the theme
Declaration
string IThemeProvider.BaseThemeName { get; set; }
Returns
Type |
---|
System.String |
IThemeProvider.ControlName
Gets the name of the control.
Declaration
string IThemeProvider.ControlName { get; }
Returns
Type |
---|
System.String |