Export (0) Print
Expand All

ScrollBar.LargeChange Property

Gets or sets a value to be added to or subtracted from the Value property when the scroll box is moved a large distance.

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

public int LargeChange { get; set; }

Property Value

Type: System.Int32
A numeric value. The default value is 10.

ExceptionCondition
ArgumentOutOfRangeException

The assigned value is less than 0.

When the user clicks in the scroll bar track on either side of the scroll box, the Value property changes according to the value set in the LargeChange property.

NoteNote

You can handle key press events so that when the user presses the PAGE UP or PAGE DOWN key the scroll box moves.

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

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. This code example is part of a larger example provided for the ScrollBar class overview.

In this example, the LargeChange property is set relative to the size of the PictureBox.

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

NoteNote

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
    }
}

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft