ToolStripLabel.LinkBehavior Property


Gets or sets a value that represents the behavior of a link.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public LinkBehavior LinkBehavior { get; set; }

Property Value

Type: System.Windows.Forms.LinkBehavior

One of the LinkBehavior values. The default is LinkBehavior.SystemDefault.

This property enables you to specify the behavior of links when they are displayed in the control. For example, if you want links to be displayed with an underline only when the mouse pointer is over a link, you can set this property to LinkBehavior.HoverUnderline. For more information about the types of behaviors that can be associated with a link, see LinkBehavior.

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()
    static void Main()
        Application.Run(new Form1());

    private void InitializeComponent()
        this.toolStrip1 = new System.Windows.Forms.ToolStrip();
        this.toolStripLabel1 = new System.Windows.Forms.ToolStripLabel();
        // toolStrip1
        this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
        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 = "";
        this.toolStripLabel1.Text = "Search MSDN";
        this.toolStripLabel1.Click += new System.EventHandler(this.toolStripLabel1_Click);
        // Form1
        this.ClientSize = new System.Drawing.Size(292, 273);
        this.Name = "Form1";


    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;

.NET Framework
Available since 2.0
Return to top