ScrollBar.SmallChange Proprietà

Definizione

Ottiene o imposta il valore da aggiungere o sottrarre alla proprietà Value quando la casella di scorrimento subisce uno spostamento ridotto.

public:
 property int SmallChange { int get(); void set(int value); };
public int SmallChange { get; set; }
member this.SmallChange : int with get, set
Public Property SmallChange As Integer

Valore della proprietà

Valore numerico. Il valore predefinito è 1.

Eccezioni

Il valore assegnato è minore di 0.

Esempio

Nell'esempio seguente si presuppone che sia stato creato un Formoggetto , aggiunto a FormPictureBox e aggiunto un oggetto orizzontale HScrollBar e un verticale VScrollBar all'oggetto PictureBox. Questo esempio di codice fa parte di un esempio più ampio fornito per la panoramica della ScrollBar classe.

In questo esempio la SmallChange proprietà viene impostata in relazione alle dimensioni dell'oggetto PictureBox.

Per eseguire questo esempio, è necessario aggiungere riferimenti agli System.Drawing spazi dei nomi e System.Windows.Forms .

Nota

Per istruzioni su come eseguire questo esempio in Visual Studio, vedere Procedura: Compilare ed eseguire un esempio di codice completo Windows Forms usando Visual Studio.

public void SetScrollBarValues()
{
    //Set the following scrollbar properties:

    //Minimum: Set to 0

    //SmallChange and LargeChange: Per UI guidelines, these must be set
    //    relative to the size of the view that the user sees, not to
    //    the total size including the unseen part.  In this example,
    //    these must be set relative to the picture box, not to the image.

    //Maximum: Calculate in steps:
    //Step 1: The maximum to scroll is the size of the unseen part.
    //Step 2: Add the size of visible scrollbars if necessary.
    //Step 3: Add an adjustment factor of ScrollBar.LargeChange.

    //Configure the horizontal scrollbar
    //---------------------------------------------
    if (this.hScrollBar1.Visible)
    {
        this.hScrollBar1.Minimum = 0;
        this.hScrollBar1.SmallChange = this.pictureBox1.Width / 20;
        this.hScrollBar1.LargeChange = this.pictureBox1.Width / 10;

        this.hScrollBar1.Maximum = this.pictureBox1.Image.Size.Width - pictureBox1.ClientSize.Width;  //step 1

        if (this.vScrollBar1.Visible) //step 2
        {
            this.hScrollBar1.Maximum += this.vScrollBar1.Width;
        }

        this.hScrollBar1.Maximum += this.hScrollBar1.LargeChange; //step 3
    }

    //Configure the vertical scrollbar
    //---------------------------------------------
    if (this.vScrollBar1.Visible)
    {
        this.vScrollBar1.Minimum = 0;
        this.vScrollBar1.SmallChange = this.pictureBox1.Height / 20;
        this.vScrollBar1.LargeChange = this.pictureBox1.Height / 10;

        this.vScrollBar1.Maximum = this.pictureBox1.Image.Size.Height - pictureBox1.ClientSize.Height; //step 1

        if (this.hScrollBar1.Visible) //step 2
        {
            this.vScrollBar1.Maximum += this.hScrollBar1.Height;
        }

        this.vScrollBar1.Maximum += this.vScrollBar1.LargeChange; //step 3
    }
}
Public Sub SetScrollBarValues()

    'Set the following scrollbar properties:

    'Minimum: Set to 0

    'SmallChange and LargeChange: Per UI guidelines, these must be set
    '    relative to the size of the view that the user sees, not to
    '    the total size including the unseen part.  In this example,
    '    these must be set relative to the picture box, not to the image.

    'Maximum: Calculate in steps:
    'Step 1: The maximum to scroll is the size of the unseen part.
    'Step 2: Add the size of visible scrollbars if necessary.
    'Step 3: Add an adjustment factor of ScrollBar.LargeChange.


    'Configure the horizontal scrollbar
    '---------------------------------------------
    If (Me.hScrollBar1.Visible) Then

        Me.hScrollBar1.Minimum = 0
        Me.hScrollBar1.SmallChange = CInt(Me.pictureBox1.Width / 20)
        Me.hScrollBar1.LargeChange = CInt(Me.pictureBox1.Width / 10)

        Me.hScrollBar1.Maximum = Me.pictureBox1.Image.Size.Width - pictureBox1.ClientSize.Width  'step 1

        If (Me.vScrollBar1.Visible) Then 'step 2

            Me.hScrollBar1.Maximum += Me.vScrollBar1.Width
        End If

        Me.hScrollBar1.Maximum += Me.hScrollBar1.LargeChange 'step 3
    End If

    'Configure the vertical scrollbar
    '---------------------------------------------
    If (Me.vScrollBar1.Visible) Then

        Me.vScrollBar1.Minimum = 0
        Me.vScrollBar1.SmallChange = CInt(Me.pictureBox1.Height / 20)
        Me.vScrollBar1.LargeChange = CInt(Me.pictureBox1.Height / 10)

        Me.vScrollBar1.Maximum = Me.pictureBox1.Image.Size.Height - pictureBox1.ClientSize.Height 'step 1

        If (Me.hScrollBar1.Visible) Then 'step 2

            Me.vScrollBar1.Maximum += Me.hScrollBar1.Height
        End If

        Me.vScrollBar1.Maximum += Me.vScrollBar1.LargeChange 'step 3
    End If
 End Sub

Commenti

Quando l'utente preme uno dei tasti di direzione o fa clic su uno dei pulsanti della barra di scorrimento, la Value proprietà cambia in base al valore impostato nella SmallChange proprietà .

Le linee guida dell'interfaccia utente suggeriscono che le SmallChange proprietà e LargeChange sono impostate in relazione alle dimensioni della visualizzazione visualizzata dall'utente, non alle dimensioni totali, inclusa la parte non visualizzata. Ad esempio, se si dispone di una casella immagine con barre di scorrimento che visualizzano un'immagine di grandi dimensioni, le SmallChange proprietà e LargeChange devono essere impostate in relazione alle dimensioni della casella immagine, non alle dimensioni dell'immagine.

Si applica a

Vedi anche