TrackBar.TickStyle Propiedad

Definición

Obtiene o establece un valor que indica cómo mostrar las marcas de paso en la barra de seguimiento.

public System.Windows.Forms.TickStyle TickStyle { get; set; }

Valor de propiedad

Uno de los valores de TickStyle. De manera predeterminada, es BottomRight.

Excepciones

El valor asignado no es un valor válido de TickStyle.

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar las TickStylepropiedades , Minimumy Maximum y cómo controlar el ValueChanged evento. Para ejecutar el ejemplo, pegue el código siguiente en un formulario que contenga un TrackBar control denominado TrackBar1 y un TextBox control denominado TextBox1. Llame al método desde el InitializeTrackBar constructor Load o el método de control de eventos del formulario.


//Declare a new TrackBar object.
internal System.Windows.Forms.TrackBar TrackBar1;

// Initialize the TrackBar and add it to the form.
private void InitializeTrackBar()
{
    this.TrackBar1 = new System.Windows.Forms.TrackBar();
    TrackBar1.Location = new System.Drawing.Point(75, 30);

    // Set the TickStyle property so there are ticks on both sides
    // of the TrackBar.
    TrackBar1.TickStyle = TickStyle.Both;

    // Set the minimum and maximum number of ticks.
    TrackBar1.Minimum = 10;
    TrackBar1.Maximum = 100;

    // Set the tick frequency to one tick every ten units.
    TrackBar1.TickFrequency = 10;

    // Associate the event-handling method with the 
    // ValueChanged event.
    TrackBar1.ValueChanged += 
        new System.EventHandler(TrackBar1_ValueChanged);
    this.Controls.Add(this.TrackBar1);
}

// Handle the TrackBar.ValueChanged event by calculating a value for
// TextBox1 based on the TrackBar value.  
private void TrackBar1_ValueChanged(object sender, System.EventArgs e)
{
    TextBox1.Text = (System.Math.Round(TrackBar1.Value/10.0)).ToString();
}

Comentarios

Puede usar la TickStyle propiedad para modificar la manera en que se muestran las marcas de graduación en la barra de pista.

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

Consulte también