ScrollBar.SmallChange ScrollBar.SmallChange ScrollBar.SmallChange ScrollBar.SmallChange Property

定义

获取或设置小距离移动滚动框时,在 Value 属性中加上或减去的值。Gets or sets the value to be added to or subtracted from the Value property when the scroll box is moved a small distance.

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

属性值

一个数值。A numeric value. 默认值为 1。The default value is 1.

异常

示例

下面的示例假定你已创建一个 Form,并将 @no__t 添加到了 Form,并向 @no__t 添加了水平 @no__t 3 和垂直 @no__t。The following example assumes that you have created a Form, added a PictureBox to the Form, and added a horizontal HScrollBar and a vertical VScrollBar to the PictureBox. 此代码示例是为 ScrollBar 类概述提供的更大示例的一部分。This code example is part of a larger example provided for the ScrollBar class overview.

在此示例中,@no__t 值设置为相对于 @no__t 的大小。In this example, the SmallChange property is set relative to the size of the PictureBox.

若要运行此示例,必须添加对 @no__t 0 和 @no__t 1 命名空间的引用。You must add references to the System.Drawing and System.Windows.Forms namespaces to run this example.

备注

有关如何在 Visual Studio 中运行此示例的说明,请参阅 [How to:使用 Visual Studio @ no__t 编译并运行完整的 Windows 窗体代码示例。For instructions about how to run this example in Visual Studio, 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
    }
}
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

注解

当用户按下某个箭头键或单击某个滚动条按钮时,@no__t 的属性将根据 SmallChange 属性中设置的值更改。When the user presses one of the arrow keys or clicks one of the scroll bar buttons, the Value property changes according to the value set in the SmallChange property.

用户界面指导原则表明,@no__t @no__t 值设置为相对于用户看到的视图大小,而不是相对于包括不可见部分的总大小。User interface guidelines suggest that the SmallChange and LargeChange properties are set relative to the size of the view that the user sees, not to the total size including the unseen part. 例如,如果具有显示大图像的滚动条的图片框,则应将 SmallChange 和 @no__t 属性设置为相对于图片框的大小,而不是相对于图像的大小。For example, if you have a picture box with scroll bars displaying a large image, the SmallChange and LargeChange properties should be set relative to the size of the picture box, not to the size of the image.

适用于

另请参阅