Поделиться через


ScrollBar.LargeChange Свойство

Определение

Возвращает или задает значение, добавляемое или вычитаемое из Value свойства при перемещении поля прокрутки на большое расстояние.

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

Значение свойства

Числовое значение. Значение по умолчанию — 10.

Исключения

Назначенное значение меньше 0.

Примеры

В следующем примере предполагается, что вы создали Formобъект, добавили в PictureBox него Formи добавили горизонтальную и вертикальную HScrollBarVScrollBar.PictureBox Этот пример кода является частью более крупного примера, предоставленного для ScrollBar обзора класса.

В этом примере LargeChange свойство задается относительно размера PictureBoxобъекта.

Для выполнения этого примера необходимо добавить ссылки на System.Drawing пространства имен и System.Windows.Forms пространства имен.

Замечание

Инструкции по запуску этого примера в Visual Studio см. в статье "Практическое руководство. Компиляция и запуск примера кода Windows Forms с помощью 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

Комментарии

Когда пользователь щелкает дорожку полосы прокрутки на любой стороне поля прокрутки, Value свойство изменяется в соответствии со значением, заданным в свойстве LargeChange .

Замечание

Вы можете обрабатывать события нажатия клавиш, чтобы пользователь нажимал клавишу PAGE UP или PAGE DOWN, перемещая поле прокрутки.

Рекомендации по пользовательскому интерфейсу показывают, что SmallChange свойства LargeChange задаются относительно размера представления, которое видит пользователь, а не общий размер, включая невидимую часть. Например, если у вас есть поле рисунка с полосами прокрутки с большим изображением, то LargeChange свойства должны быть заданы относительно размера поля рисунка, SmallChange а не размера изображения.

Применяется к

См. также раздел