Auf Englisch lesen

Freigeben über


TrackBar.LargeChange Eigenschaft

Definition

Ruft einen Wert ab, der zur Value-Eigenschaft addiert oder von dieser subtrahiert werden soll, wenn das Bildlauffeld um einen größeren Abstand verschoben wird, oder legt diesen fest.

C#
public int LargeChange { get; set; }

Eigenschaftswert

Ein numerischer Wert. Der Standardwert ist 5.

Ausnahmen

Der zugewiesene Wert ist kleiner als 0.

Beispiele

Im folgenden Codebeispiel wird ein Formular angezeigt, das ein TrackBar -Steuerelement und ein TextBox -Steuerelement enthält. Das Beispiel veranschaulicht das Festlegen der MaximumEigenschaften , TickFrequency, LargeChangeund sowie SmallChange die Behandlung des Ereignisses Scroll . Der TextBox Inhalt wird auf den Value Eigenschaftswert aktualisiert, wenn das Scroll Ereignis eintritt.

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

public class Form1 : System.Windows.Forms.Form
{
    private System.Windows.Forms.TrackBar trackBar1;
    private System.Windows.Forms.TextBox textBox1;

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

    public Form1()
    {
        this.textBox1 = new System.Windows.Forms.TextBox();
        this.trackBar1 = new System.Windows.Forms.TrackBar();

        // TextBox for TrackBar.Value update.
        this.textBox1.Location = new System.Drawing.Point(240, 16);
        this.textBox1.Size = new System.Drawing.Size(48, 20);

        // Set up how the form should be displayed and add the controls to the form.
        this.ClientSize = new System.Drawing.Size(296, 62);
        this.Controls.AddRange(new System.Windows.Forms.Control[] {this.textBox1,this.trackBar1});
        this.Text = "TrackBar Example";

        // Set up the TrackBar.
        this.trackBar1.Location = new System.Drawing.Point(8, 8);
        this.trackBar1.Size = new System.Drawing.Size(224, 45);
        this.trackBar1.Scroll += new System.EventHandler(this.trackBar1_Scroll);

        // The Maximum property sets the value of the track bar when
        // the slider is all the way to the right.
        trackBar1.Maximum = 30;
        
        // The TickFrequency property establishes how many positions
        // are between each tick-mark.
        trackBar1.TickFrequency = 5;

        // The LargeChange property sets how many positions to move
        // if the bar is clicked on either side of the slider.
        trackBar1.LargeChange = 3;

        // The SmallChange property sets how many positions to move
        // if the keyboard arrows are used to move the slider.
        trackBar1.SmallChange = 2;
    }

    private void trackBar1_Scroll(object sender, System.EventArgs e)
    {
        // Display the trackbar value in the text box.
        textBox1.Text = "" + trackBar1.Value;
    }
}

Hinweise

Wenn der Benutzer die BILD-NACH-OBEN- oder BILD-NACH-UNTEN-TASTE drückt oder auf die Spurleiste auf beiden Seiten des Bildlauffelds klickt, ändert sich die Value Eigenschaft entsprechend dem in der LargeChange -Eigenschaft festgelegten Wert. Sie können erwägen, den LargeChange Wert auf einen Prozentsatz des Height Werts (für eine vertikal ausgerichtete Spurleiste) oder Width (für eine horizontal ausgerichtete Spurleiste) festzulegen. Dadurch bleibt der Abstand, den die Spurleiste bewegt, proportional zu ihrer Größe.

Gilt für:

Produkt Versionen
.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