ToolStripLabel Class
Assembly: System.Windows.Forms (in system.windows.forms.dll)
Use the ToolStripLabel class to create a label that can render text and images that can implement the ToolStripItem.TextAlign and ToolStripItem.ImageAlign properties. The ToolStripLabel also has many properties that enable it to display one or more hyperlinks, and other properties that modify the appearance and behavior of hyperlinks.
The ToolStripLabel is like a ToolStripButton that does not get focus by default and that does not render as pushed or highlighted.
ToolStripLabel as a hosted item supports access keys.
Use the LinkColor, LinkVisited, and LinkBehavior properties on a ToolStripLabel to support link control in a ToolStrip.
The following code example demonstrates how to initialize a ToolStripLabel to contain a link by setting the IsLink, LinkColor, ActiveLinkColor, VisitedLinkColor, LinkVisited and LinkBehavior properties.
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 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.