DekGenius.com
[ Team LiB ] Previous Section Next Section

Labelmarshal by reference, disposable

System.Windows.Forms (system.windows.forms.dll)class

This Control provides a simple, non-editable text label.

The control has the ability to AutoSize to the content, although care should be taken to ensure that the layout engine can cope with this neatly. If you set the UseMnemonic property to true, you can use Alt key shortcuts. The control strips out the first &, underlines the subsequent character, and ensures that the focus is set to the next element in the tab order when the Alt key combination is pressed. The label itself cannot receive the focus.

In addition to the Text, you can add an Image or an item from an ImageList (the one at a particular ImageIndex).

Alternatively, you can set the FlatStyle to System, and fall back on the standard OS rendering, perhaps for XP theme support. You lose the image support, however.

public class Label : Control {
// Public Constructors
   public Label();
// Public Instance Properties
   public virtual bool AutoSize{set; get; }
   public override Image BackgroundImage{set; get; }
// overrides Control
   public virtual BorderStyle BorderStyle{set; get; }
   public FlatStyle FlatStyle{set; get; }
   public Image Image{set; get; }
   public ContentAlignment ImageAlign{set; get; }
   public int ImageIndex{set; get; }
   public ImageList ImageList{set; get; }
   public ImeMode ImeMode{set; get; }
// overrides Control
   public virtual int PreferredHeight{get; }
   public virtual int PreferredWidth{get; }
   public bool TabStop{set; get; }
// overrides Control
   public virtual ContentAlignment TextAlign{set; get; }
   public bool UseMnemonic{set; get; }
// Protected Instance Properties
   protected override CreateParams CreateParams{get; }
// overrides Control
   protected override ImeMode DefaultImeMode{get; }
// overrides Control
   protected override Size DefaultSize{get; }
// overrides Control
   protected virtual bool RenderTransparent{set; get; }
// overrides Control
// Public Instance Methods
   public override string ToString();  // overrides System.ComponentModel.Component
// Protected Instance Methods
   protected Rectangle CalcImageRenderBounds(System.Drawing.Image image, System.Drawing.Rectangle r, 
        System.Drawing.ContentAlignment align);
   protected override AccessibleObject CreateAccessibilityInstance();  // overrides Control
   protected override void Dispose(bool disposing);  // overrides Control
   protected void DrawImage(System.Drawing.Graphics g, System.Drawing.Image image, 
        System.Drawing.Rectangle r, System.Drawing.ContentAlignment align);
   protected virtual void OnAutoSizeChanged(EventArgs e);
   protected override void OnEnabledChanged(EventArgs e);  // overrides Control
   protected override void OnFontChanged(EventArgs e);  // overrides Control
   protected override void OnPaint(PaintEventArgs e);  // overrides Control
   protected override void OnParentChanged(EventArgs e);  // overrides Control
   protected virtual void OnTextAlignChanged(EventArgs e);
   protected override void OnTextChanged(EventArgs e);  // overrides Control
   protected override void OnVisibleChanged(EventArgs e);  // overrides Control
   protected override bool ProcessMnemonic(char charCode);  // overrides Control
   protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified);  // overrides Control
   protected override void WndProc(ref Message m);  // overrides Control
// Events
   public event EventHandler AutoSizeChanged;
   public event KeyEventHandler KeyDown;
// overrides Control
   public event KeyPressEventHandler KeyPress;
// overrides Control
   public event KeyEventHandler KeyUp;
// overrides Control
   public event EventHandler TextAlignChanged;
}

Hierarchy

System.Object System.MarshalByRefObject System.ComponentModel.Component(System.ComponentModel.IComponen, System.IDisposable) Control(IOleContro, IOleObject, IOleInPlaceObject, IOleInPlaceActiveObject, IOleWindow, IViewObject, IViewObject2, IPersist, IPersistStreamInit, IPersistPropertyBag, IPersistStorage, IQuickActivate, System.ComponentModel.ISynchronizeInvoke, IWin32Window) Label

Subclasses

LinkLabel

    [ Team LiB ] Previous Section Next Section