Export (0) Print
Expand All

DataGridViewLinkColumn.LinkBehavior Property

Gets or sets a value that represents the behavior of links within cells in the column.

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
A LinkBehavior value indicating the link behavior. The default is SystemDefault.

ExceptionCondition
InvalidOperationException

The value of the CellTemplate property is null.

Getting or setting this property gets or sets the LinkBehavior property of the object returned by the CellTemplate property. Setting this property also sets the LinkBehavior 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 this property to SystemDefault, which lets the operating system choose how the link will display. 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.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft