TrackBar.TickStyle Proprietà

Definizione

Ottiene o imposta un valore che indica come visualizzare i segni di graduazione sull'indicatore di avanzamento.

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

Valore della proprietà

Uno dei valori di TickStyle. Il valore predefinito è BottomRight.

Eccezioni

Il valore assegnato non è un valore di TickStyle valido.

Esempio

Nell'esempio di codice seguente viene illustrato come usare le TickStyleproprietà , Minimume Maximum e come gestire l'evento ValueChanged . Per eseguire l'esempio, incollare il codice seguente in una maschera contenente un TrackBar controllo denominato TrackBar1 e un TextBox controllo denominato TextBox1. Chiamare il InitializeTrackBar metodo dal costruttore Load o dal metodo di gestione degli eventi del modulo.

C#

//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();
}

Commenti

È possibile utilizzare la TickStyle proprietà per modificare il modo in cui i segni di graduazione vengono visualizzati sulla barra delle tracce.

Si applica a

Prodotto Versioni
.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

Vedi anche