Este artigo foi traduzido por máquina. Para visualizar o arquivo em inglês, marque a caixa de seleção Inglês. Você também pode exibir o texto Em inglês em uma janela pop-up, movendo o ponteiro do mouse sobre o texto.
Tradução
Inglês

Propriedade ScrollBar.SmallChange

 

Obtém ou define o valor a ser adicionado ou subtraído da propriedade Value quando a caixa de rolagem é movida por uma distância pequena.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (em System.Windows.Forms.dll)

public int SmallChange { get; set; }

Valor da Propriedade

Type: System.Int32

Um valor numérico. O valor padrão é 1.

Exception Condition
ArgumentOutOfRangeException

O valor atribuído é menor que 0.

When the user presses one of the arrow keys or clicks one of the scroll bar buttons, the P:System.Windows.Forms.ScrollBar.Value property changes according to the value set in the P:System.Windows.Forms.ScrollBar.SmallChange property.

User interface guidelines suggest that the P:System.Windows.Forms.ScrollBar.SmallChange and P:System.Windows.Forms.ScrollBar.LargeChange properties are set relative to the size of the view that the user sees, not to the total size including the unseen part. For example, if you have a picture box with scroll bars displaying a large image, the P:System.Windows.Forms.ScrollBar.SmallChange and P:System.Windows.Forms.ScrollBar.LargeChange properties should be set relative to the size of the picture box, not to the size of the image.

The following example assumes that you have created a T:System.Windows.Forms.Form, added a T:System.Windows.Forms.PictureBox to the T:System.Windows.Forms.Form, and added a horizontal T:System.Windows.Forms.HScrollBar and a vertical T:System.Windows.Forms.VScrollBar to the T:System.Windows.Forms.PictureBox. This code example is part of a larger example provided for the T:System.Windows.Forms.ScrollBar class overview.

In this example, the P:System.Windows.Forms.ScrollBar.SmallChange property is set relative to the size of the T:System.Windows.Forms.PictureBox.

You must add references to the N:System.Drawing and N:System.Windows.Forms namespaces to run this example.

System_CAPS_noteObservação

For instructions about how to run this example in vsprvs, see 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
    }
}

.NET Framework
Disponível desde 1.1
Retornar ao início
Mostrar: