ScrollBar.SmallChange Propiedad

Definición

Obtiene o establece el valor que se suma o se resta de la propiedad Value cuando el cuadro de desplazamiento se mueve una distancia pequeña.

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

Valor de propiedad

Int32

Valor numérico. El valor predeterminado es 1.

Excepciones

El valor asignado es menor que 0.

Ejemplos

En el ejemplo siguiente se da por hecho que ha creado un Formelemento , ha agregado un elemento a Formy ha agregado PictureBox un horizontal HScrollBar y un vertical VScrollBar a PictureBox. Este ejemplo de código forma parte de un ejemplo más grande proporcionado para la información general de la ScrollBar clase.

En este ejemplo, la SmallChange propiedad se establece en relación con el tamaño de PictureBox.

Debe agregar referencias a los System.Drawing espacios de nombres y System.Windows.Forms para ejecutar este ejemplo.

Nota

Para obtener instrucciones sobre cómo ejecutar este ejemplo en Visual Studio, vea How to: Compile and Run a Complete Windows Forms Code Example Using 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

Comentarios

Cuando el usuario presiona una de las teclas de dirección o hace clic en uno de los botones de la barra de desplazamiento, la Value propiedad cambia según el valor establecido en la SmallChange propiedad .

Las instrucciones de la interfaz de usuario sugieren que las SmallChange propiedades y LargeChange se establecen en relación con el tamaño de la vista que ve el usuario, no en el tamaño total, incluido el elemento no visto. Por ejemplo, si tiene un cuadro de imagen con barras de desplazamiento que muestran una imagen grande, las SmallChange propiedades y LargeChange deben establecerse en relación con el tamaño del cuadro de imagen, no con el tamaño de la imagen.

Se aplica a

Consulte también