Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

DataGridViewLinkColumn.ActiveLinkColor Property

Gets or sets the color used to display an active link within cells in the column.

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

public Color ActiveLinkColor { get; set; }

Property Value

Type: System.Drawing.Color
A Color that represents the color used to display a link that is being selected. The default value is the user's Internet Explorer setting for the color of links in the hover state.

ExceptionCondition
InvalidOperationException

The value of the CellTemplate property is null.

Getting or setting this property gets or sets the ActiveLinkColor property of the object returned by the CellTemplate property. Setting this property also sets the ActiveLinkColor 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.

The following code example initializes the ActiveLinkColor property so that the link turns white when the user selects it. 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);
}

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft