ToolStripLabel, classe
Mise à jour : novembre 2007
Représente un ToolStripItem impossible à sélectionner qui restitue le texte et les images et peut afficher des liens hypertexte.
Assembly : System.Windows.Forms (dans System.Windows.Forms.dll)
[ToolStripItemDesignerAvailabilityAttribute(ToolStripItemDesignerAvailability.ToolStrip)] public class ToolStripLabel : ToolStripItem
/** @attribute ToolStripItemDesignerAvailabilityAttribute(ToolStripItemDesignerAvailability.ToolStrip) */ public class ToolStripLabel extends ToolStripItem
public class ToolStripLabel extends ToolStripItem
Utilisez la classe ToolStripLabel pour créer une étiquette qui peut restituer le texte et les images qui peuvent implémenter les propriétés ToolStripItem.TextAlign et ToolStripItem.ImageAlign. ToolStripLabel dispose également de nombreuses propriétés qui lui permettent d'afficher un ou plusieurs liens hypertexte et d'autres propriétés qui modifient l'apparence et comportement de liens hypertexte.
ToolStripLabel est semblable à un ToolStripButton qui n'obtient pas le focus par défaut et qui n'est pas affiché comme étant enfoncé ou mis en surbrillance.
ToolStripLabel, en tant qu'élément hébergé, prend en charge les touches d'accès rapide.
Utilisez les propriétés LinkColor, LinkVisited et LinkBehavior sur un ToolStripLabel pour prendre en charge le contrôle de lien dans ToolStrip.
L'exemple de code suivant montre comment initialiser ToolStripLabel de sorte qu'il contienne un lien en définissant les propriétés IsLink, LinkColor, ActiveLinkColor, VisitedLinkColor, LinkVisited et LinkBehavior.
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; public class Form1 : Form { private ToolStripLabel toolStripLabel1; private ToolStrip toolStrip1; public Form1() { InitializeComponent(); } [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } private void InitializeComponent() { this.toolStrip1 = new System.Windows.Forms.ToolStrip(); this.toolStripLabel1 = new System.Windows.Forms.ToolStripLabel(); this.toolStrip1.SuspendLayout(); this.SuspendLayout(); // // toolStrip1 // this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripLabel1}); this.toolStrip1.Location = new System.Drawing.Point(0, 0); this.toolStrip1.Name = "toolStrip1"; this.toolStrip1.Size = new System.Drawing.Size(292, 25); this.toolStrip1.TabIndex = 0; this.toolStrip1.Text = "toolStrip1"; // // toolStripLabel1 // this.toolStripLabel1.IsLink = true; this.toolStripLabel1.LinkBehavior = System.Windows.Forms.LinkBehavior.AlwaysUnderline; this.toolStripLabel1.Name = "toolStripLabel1"; this.toolStripLabel1.Size = new System.Drawing.Size(71, 22); this.toolStripLabel1.Tag = "http://search.microsoft.com/search/search.aspx?"; this.toolStripLabel1.Text = "Search MSDN"; this.toolStripLabel1.Click += new System.EventHandler(this.toolStripLabel1_Click); // // Form1 // this.ClientSize = new System.Drawing.Size(292, 273); this.Controls.Add(this.toolStrip1); this.Name = "Form1"; this.toolStrip1.ResumeLayout(false); this.toolStrip1.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); } private void toolStripLabel1_Click(object sender, EventArgs e) { ToolStripLabel toolStripLabel1 = (ToolStripLabel)sender; // Start Internet Explorer and navigate to the URL in the // tag property. System.Diagnostics.Process.Start("IEXPLORE.EXE", toolStripLabel1.Tag.ToString()); // Set the LinkVisited property to true to change the color. toolStripLabel1.LinkVisited = true; } }
System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.ToolStripItem
System.Windows.Forms.ToolStripLabel
System.Windows.Forms.ToolStripStatusLabel
Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professionnel Édition x64, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
Le .NET Framework et le .NET Compact Framework ne prennent pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.