DataGridViewLinkColumn.TrackVisitedState Property

Definition

Gets or sets a value indicating whether the link changes color if it has been visited.

public bool TrackVisitedState { get; set; }

Property Value

true if the link changes color when it is selected; otherwise, false. The default is true.

Exceptions

The value of the CellTemplate property is null.

Examples

The following code example initializes this property so that the link changes color when it is selected. This example is part of a larger example available in the DataGridViewComboBoxColumn class overview topic.

private void AddLinkColumn()
{
    DataGridViewLinkColumn links = new DataGridViewLinkColumn();

    links.UseColumnTextForLinkValue = true;
    links.HeaderText = ColumnName.ReportsTo.ToString();
    links.DataPropertyName = ColumnName.ReportsTo.ToString();
    links.ActiveLinkColor = Color.White;
    links.LinkBehavior = LinkBehavior.SystemDefault;
    links.LinkColor = Color.Blue;
    links.TrackVisitedState = true;
    links.VisitedLinkColor = Color.YellowGreen;

    DataGridView1.Columns.Add(links);
}

Remarks

When TrackVisitedState is true, the VisitedLinkColor property value is used to display links that have already been visited.

Getting or setting this property gets or sets the TrackVisitedState property of the object returned by the CellTemplate property. Setting this property also sets the TrackVisitedState property of every cell in the column and refreshes the column display. To override the specified value for individual cells, set the cell values after you set the column value.

Applies to

Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

See also