TabControl.HotTrack Propiedad

Definición

Obtiene o establece un valor que indica si las pestañas del control cambian de apariencia cuando el mouse pasa sobre ellas.

C#
public bool HotTrack { get; set; }

Valor de propiedad

true si las pestañas cambian de apariencia cuando el mouse pasa sobre ellas; de lo contrario, false. El valor predeterminado es false.

Ejemplos

En el ejemplo de código siguiente se crea un TabControl con dos objetos TabPage. La propiedad HotTrack se establece en true, que resalta la pestaña TextmyTabPage1 o myTabPage2 cuando el mouse pasa sobre las pestañas.

C#
using System.Drawing;
using System.Windows.Forms;

public class Form1 : Form
{
    private TabControl tabControl1;
    private TabPage tabPage1;
    private TabPage tabPage2;

    private void MyTabs()
    {
        this.tabControl1 = new TabControl();
        this.tabPage1 = new TabPage();
        this.tabPage2 = new TabPage();

        this.tabControl1.Controls.AddRange(new Control[] {
            this.tabPage1,
            this.tabPage2});
        this.tabControl1.Padding = new Point(15, 10);
        this.tabControl1.Location = new Point(35, 25);
        this.tabControl1.Size = new Size(220, 220);

        // Highlights TabPage.Text when the mouse passes over tabs.
        this.tabControl1.HotTrack = true;
    
        this.tabPage1.Text = "myTabPage1";
        this.tabPage2.Text = "myTabPage2";

        this.Size = new Size(300, 300);
        this.Controls.AddRange(new Control[] {
            this.tabControl1});
    }
    
    public Form1()
    {
        MyTabs();
    }

    static void Main() 
    {
        Application.Run(new Form1());
    }
}

Comentarios

El color al que cambia la pestaña cuando el mouse está sobre él viene determinado por los colores del sistema del equipo local. Para cambiar los colores del sistema, use el Panel de control.

Se aplica a

Producto Versiones
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10