ToolStripLabel.LinkVisited Property


Gets or sets a value indicating whether a link should be displayed as though it were visited.

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

public bool LinkVisited { get; set; }

Property Value

Type: System.Boolean

true if links should display as though they were visited; otherwise, false. The default is false.

A LinkLabel control does not automatically denote that a link is a visited link. To display the link as a visited link, you can set the value of this property to true in an event handler for the click event of the LinkLabel. A visited link is displayed using the color specified in the VisitedLinkColor property of the ToolStripLabel control.

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