編輯

共用方式為


DataGridViewLinkCell.LinkBehavior Property

Definition

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

public:
 property System::Windows::Forms::LinkBehavior LinkBehavior { System::Windows::Forms::LinkBehavior get(); void set(System::Windows::Forms::LinkBehavior value); };
public System.Windows.Forms.LinkBehavior LinkBehavior { get; set; }
member this.LinkBehavior : System.Windows.Forms.LinkBehavior with get, set
Public Property LinkBehavior As LinkBehavior

Property Value

One of the LinkBehavior values. The default is SystemDefault.

Exceptions

The specified value when setting this property is not a valid LinkBehavior value.

Examples

The following code example demonstrates the use of the DataGridViewLinkColumn.LinkBehavior property, which is similar to this property. This example is part of a larger example available in the DataGridViewComboBoxColumn class overview topic.

private:
    void AddLinkColumn()
    {
        DataGridViewLinkColumn^ links = gcnew 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);
    }
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);
}
Private Sub AddLinkColumn()

    Dim links As New DataGridViewLinkColumn()
    With links
        .UseColumnTextForLinkValue = True
        .HeaderText = ColumnName.ReportsTo.ToString()
        .DataPropertyName = ColumnName.ReportsTo.ToString()
        .ActiveLinkColor = Color.White
        .LinkBehavior = LinkBehavior.SystemDefault
        .LinkColor = Color.Blue
        .TrackVisitedState = True
        .VisitedLinkColor = Color.YellowGreen
    End With
    DataGridView1.Columns.Add(links)
End Sub

Remarks

Examples of link behavior include whether the link always displays an underline or the link only displays an underline when the mouse pointer moves over it, and whether a double click or a single click activates a link.

Setting the LinkBehavior property of the owning column 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.

Applies to

See also