ToolStripLabel.ActiveLinkColor Propiedad

Definición

Obtiene o establece el color utilizado para mostrar un vínculo activo.

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

Valor de propiedad

Color que representa el color en que se mostrará un vínculo activo. El sistema especifica el color predeterminado. Normalmente, este color es Color.Red.

Ejemplos

En el ejemplo de código siguiente se muestra cómo inicializar un ToolStripLabel objeto para que contenga un vínculo estableciendo las IsLinkpropiedades , LinkColor, ActiveLinkColor, VisitedLinkColory LinkVisitedLinkBehavior .

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

public class Form1 : Form
{
    private ToolStripLabel toolStripLabel1;
    private ToolStrip toolStrip1;

    public Form1()
    {
        InitializeComponent();
    }
    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new Form1());
    }

    private void InitializeComponent()
    {
        this.toolStrip1 = new System.Windows.Forms.ToolStrip();
        this.toolStripLabel1 = new System.Windows.Forms.ToolStripLabel();
        this.toolStrip1.SuspendLayout();
        this.SuspendLayout();
        // 
        // toolStrip1
        // 
        this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.toolStripLabel1});
        this.toolStrip1.Location = new System.Drawing.Point(0, 0);
        this.toolStrip1.Name = "toolStrip1";
        this.toolStrip1.Size = new System.Drawing.Size(292, 25);
        this.toolStrip1.TabIndex = 0;
        this.toolStrip1.Text = "toolStrip1";
        // 
        // toolStripLabel1
        // 
        this.toolStripLabel1.IsLink = true;
        this.toolStripLabel1.LinkBehavior = System.Windows.Forms.LinkBehavior.AlwaysUnderline;
        this.toolStripLabel1.Name = "toolStripLabel1";
        this.toolStripLabel1.Size = new System.Drawing.Size(71, 22);
        this.toolStripLabel1.Tag = "http://search.microsoft.com/search/search.aspx?";
        this.toolStripLabel1.Text = "Search MSDN";
        this.toolStripLabel1.Click += new System.EventHandler(this.toolStripLabel1_Click);
        // 
        // Form1
        // 
        this.ClientSize = new System.Drawing.Size(292, 273);
        this.Controls.Add(this.toolStrip1);
        this.Name = "Form1";
        this.toolStrip1.ResumeLayout(false);
        this.toolStrip1.PerformLayout();
        this.ResumeLayout(false);
        this.PerformLayout();
    }

    private void toolStripLabel1_Click(object sender, EventArgs e)
    {
        ToolStripLabel toolStripLabel1 = (ToolStripLabel)sender;

        // Start Internet Explorer and navigate to the URL in the
        // tag property.
        System.Diagnostics.Process.Start("IEXPLORE.EXE", toolStripLabel1.Tag.ToString());

        // Set the LinkVisited property to true to change the color.
        toolStripLabel1.LinkVisited = true;
    }
}
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms

Public Class Form1
   Inherits Form
   Private WithEvents toolStripLabel1 As ToolStripLabel
   Private toolStrip1 As ToolStrip
   
   Public Sub New()
      InitializeComponent()
   End Sub
   
   <STAThread()>  _
   Shared Sub Main()
      Application.EnableVisualStyles()
      Application.SetCompatibleTextRenderingDefault(False)
      Application.Run(New Form1())
   End Sub
   
   
   Private Sub InitializeComponent()
      Me.toolStrip1 = New System.Windows.Forms.ToolStrip()
      Me.toolStripLabel1 = New System.Windows.Forms.ToolStripLabel()
      Me.toolStrip1.SuspendLayout()
      Me.SuspendLayout()
      ' 
      ' toolStrip1
      ' 
      Me.toolStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.toolStripLabel1})
      Me.toolStrip1.Location = New System.Drawing.Point(0, 0)
      Me.toolStrip1.Name = "toolStrip1"
      Me.toolStrip1.Size = New System.Drawing.Size(292, 25)
      Me.toolStrip1.TabIndex = 0
      Me.toolStrip1.Text = "toolStrip1"
      ' 
      ' toolStripLabel1
      ' 
      Me.toolStripLabel1.IsLink = True
      Me.toolStripLabel1.LinkBehavior = System.Windows.Forms.LinkBehavior.AlwaysUnderline
      Me.toolStripLabel1.Name = "toolStripLabel1"
      Me.toolStripLabel1.Size = New System.Drawing.Size(71, 22)
      Me.toolStripLabel1.Tag = "http://search.microsoft.com/search/search.aspx?"
      Me.toolStripLabel1.Text = "Search MSDN"
      ' 
      ' Form1
      ' 
      Me.ClientSize = New System.Drawing.Size(292, 273)
      Me.Controls.Add(toolStrip1)
      Me.Name = "Form1"
      Me.toolStrip1.ResumeLayout(False)
      Me.toolStrip1.PerformLayout()
      Me.ResumeLayout(False)
      Me.PerformLayout()
   End Sub
    
   
   Private Sub toolStripLabel1_Click(sender As Object, e As EventArgs) Handles toolStripLabel1.Click
      Dim toolStripLabel1 As ToolStripLabel = CType(sender, ToolStripLabel)
      
      ' Start Internet Explorer and navigate to the URL in the
      ' tag property.
      System.Diagnostics.Process.Start("IEXPLORE.EXE", toolStripLabel1.Tag.ToString())
      
      ' Set the LinkVisited property to true to change the color.
      toolStripLabel1.LinkVisited = True
   End Sub
End Class

Comentarios

Un vínculo activo es un vínculo en el que se hace clic en el proceso de hacer clic. Esto es similar al estado deprimida de un Button control. Puede usar esta propiedad para especificar el color en el que se muestra el vínculo cuando el vínculo está en proceso de hacer clic en el vínculo.

Hay una serie de colores asociados a un vínculo. LinkColor especifica el color de todos los vínculos que se muestran en el LinkLabel control . La VisitedLinkColor propiedad permite especificar el color de un vínculo después de que el usuario lo haya visitado.

Nota

Al establecer esta propiedad, asegúrese de que el color en el que está estableciendo la propiedad no entra en conflicto con el color del fondo del control o el texto no se muestra correctamente. Por ejemplo, si el color de fondo del control es Color.Red y esta propiedad se establece Color.Reden , el texto no se muestra correctamente cuando el vínculo está en proceso de hacer clic en este.

Se aplica a