DataGridViewLinkColumn.LinkColor DataGridViewLinkColumn.LinkColor DataGridViewLinkColumn.LinkColor DataGridViewLinkColumn.LinkColor Property

定义

获取或设置用于在列的单元格中显示未选中的链接的颜色。Gets or sets the color used to display an unselected link within cells in the column.

public:
 property System::Drawing::Color LinkColor { System::Drawing::Color get(); void set(System::Drawing::Color value); };
public System.Drawing.Color LinkColor { get; set; }
member this.LinkColor : System.Drawing.Color with get, set
Public Property LinkColor As Color

属性值

Color,表示用来显示链接的初始颜色。A Color that represents the color used to initially display a link. 默认值为用户的 Internet Explorer 中的链接颜色设置。The default value is the user's Internet Explorer setting for the link color.

异常

示例

下面的代码示例将此属性初始化为蓝色。The following code example initializes this property to blue. 此示例是DataGridViewComboBoxColumn类概述主题中提供的一个更大示例的一部分。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

注解

获取或设置此属性将获取或设置LinkColor CellTemplate由属性返回的对象的属性。Getting or setting this property gets or sets the LinkColor property of the object returned by the CellTemplate property. 设置此属性还会设置LinkColor列中每个单元格的属性, 并刷新列显示。Setting this property also sets the LinkColor 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.

适用于

另请参阅