TrackBar.Minimum Proprietà

Definizione

Ottiene o imposta il limite inferiore dell'intervallo utilizzato dal controllo TrackBar.

C#
public int Minimum { get; set; }

Valore della proprietà

Valore minimo del controllo TrackBar. Il valore predefinito è 0.

Esempio

Nell'esempio di codice seguente viene illustrato come usare i TickFrequencymembri , 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 usare il SetRange metodo per impostare contemporaneamente le Maximum proprietà e Minimum .

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