Freigeben über


ScrollBar.SmallChange-Eigenschaft

Ruft den Wert ab, der zur Value-Eigenschaft addiert oder von dieser subtrahiert werden soll, wenn das Bildlauffeld um eine kleine Strecke verschoben wird, oder legt diesen fest.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
Public Property SmallChange As Integer
'Usage
Dim instance As ScrollBar
Dim value As Integer

value = instance.SmallChange

instance.SmallChange = value
public int SmallChange { get; set; }
public:
property int SmallChange {
    int get ();
    void set (int value);
}
/** @property */
public int get_SmallChange ()

/** @property */
public void set_SmallChange (int value)
public function get SmallChange () : int

public function set SmallChange (value : int)

Eigenschaftenwert

Ein numerischer Wert. Der Standardwert ist 1.

Ausnahmen

Ausnahmetyp Bedingung

ArgumentOutOfRangeException

Der zugewiesene Wert ist kleiner als 0.

Hinweise

Wenn Benutzer eine der Pfeiltasten drücken oder auf eine der Schaltflächen der Bildlaufleiste klicken, wird die Value-Eigenschaft entsprechend dem in der SmallChange-Eigenschaft festgelegten Wert geändert.

Sie können den SmallChange-Wert auch auf einen Prozentsatz des Height-Werts (bei einer vertikalen Bildlaufleiste) oder des Width-Werts (bei einer horizontalen Bildlaufleiste) festlegen. Dadurch verhält sich der Abstand, um den die Bildlaufleiste verschoben wird, relativ zu ihrer Größe.

Beispiel

Im folgenden Codebeispiel werden die abgeleitete VScrollBar-Klasse und HScrollBar-Klasse verwendet und einige ihrer allgemeinen Eigenschaften festgelegt. Die Maximum-Eigenschaften werden entsprechend der Height oder der Width des Image festgelegt, das dem übergeordneten Element, einer PictureBox, zugewiesen ist. Die LargeChange-Eigenschaft wird entsprechend der Größe des Bildfelds festgelegt, abzüglich der Höhe und Breite der Bildlaufleisten. Die SmallChange-Eigenschaft wird gleich dem LargeChange-Eigenschaftenwert geteilt durch 5 festgelegt. Schließlich werden die Value-Eigenschaftenwerte für beide Bildlaufleisten auf 0 festgelegt. Dadurch werden die vertikale und die horizontale Bildlaufleiste in einem Bildfeld angezeigt, in dem die obere linke Ecke von Image angezeigt wird. Sie können mit den Bildlaufleisten keinen Bildlauf über den Rand des Bildes hinaus durchführen, und bei einem LargeChange-Bildlauf verschiebt sich das Bild nur so weit, wie auch der im Bildfeld angezeigte Bereich verschoben wird. Fünf SmallChange-Bildläufe entsprechen dem Verschiebungsabstand eines LargeChange-Bildlaufs. In diesem Code wird davon ausgegangen, dass in einem Form eine PictureBox, eine HScrollBar, eine VScrollBar und ein Image erstellt wurden. Außerdem wird davon ausgegangen, dass ein Verweis auf den System.Drawing-Namespace hinzugefügt wurde. Zusätzlichen Code für die Erweiterung dieses Beispiels finden Sie in der Übersicht zur ScrollBar-Klasse.

Public Sub SetScrollBarValues()
   ' Set the Maximum, Minimum, LargeChange and SmallChange properties.
   Me.vScrollBar1.Minimum = 0
   Me.hScrollBar1.Minimum = 0
   
   ' If the offset does not make the Maximum less than zero, set its value.
   If Me.pictureBox1.Image.Size.Width - pictureBox1.ClientSize.Width > 0 Then
      Me.hScrollBar1.Maximum = Me.pictureBox1.Image.Size.Width - _
        pictureBox1.ClientSize.Width
   End If
   ' If the VScrollBar is visible, adjust the Maximum of the 
   ' HSCrollBar to account for the width of the VScrollBar.
   If Me.vScrollBar1.Visible Then
      Me.hScrollBar1.Maximum += Me.vScrollBar1.Width
   End If
   Me.hScrollBar1.LargeChange = Me.hScrollBar1.Maximum / 10
   Me.hScrollBar1.SmallChange = Me.hScrollBar1.Maximum / 20
   ' Adjust the Maximum value to make the raw Maximum value attainable by user interaction.
   Me.hScrollBar1.Maximum += Me.hScrollBar1.LargeChange
         
   ' If the offset does not make the Maximum less than zero, set its value.
   If Me.pictureBox1.Image.Size.Height - pictureBox1.ClientSize.Height > 0 Then
      Me.vScrollBar1.Maximum = Me.pictureBox1.Image.Size.Height - _
        pictureBox1.ClientSize.Height
   End If
   ' If the HScrollBar is visible, adjust the Maximum of the 
   ' VSCrollBar to account for the width of the HScrollBar.
   If Me.hScrollBar1.Visible Then
      Me.vScrollBar1.Maximum += Me.hScrollBar1.Height
   End If
   Me.vScrollBar1.LargeChange = Me.vScrollBar1.Maximum / 10
   Me.vScrollBar1.SmallChange = Me.vScrollBar1.Maximum / 20
   ' Adjust the Maximum value to make the raw Maximum value attainable by user interaction.
   Me.vScrollBar1.Maximum += Me.vScrollBar1.LargeChange
End Sub
public void SetScrollBarValues() 
{
   // Set the Maximum, Minimum, LargeChange and SmallChange properties.
   this.vScrollBar1.Minimum = 0;
   this.hScrollBar1.Minimum = 0;
   // If the offset does not make the Maximum less than zero, set its value. 
   if( (this.pictureBox1.Image.Size.Width - pictureBox1.ClientSize.Width) > 0)
   {
      this.hScrollBar1.Maximum = this.pictureBox1.Image.Size.Width - pictureBox1.ClientSize.Width;
   }
   /* If the VScrollBar is visible, adjust the Maximum of the 
      HSCrollBar to account for the width of the VScrollBar. */
   if(this.vScrollBar1.Visible)
   {
      this.hScrollBar1.Maximum += this.vScrollBar1.Width;
   }
   this.hScrollBar1.LargeChange = this.hScrollBar1.Maximum / 10;
   this.hScrollBar1.SmallChange = this.hScrollBar1.Maximum / 20;
   // Adjust the Maximum value to make the raw Maximum value attainable by user interaction.
   this.hScrollBar1.Maximum += this.hScrollBar1.LargeChange;
     
   // If the offset does not make the Maximum less than zero, set its value.    
   if( (this.pictureBox1.Image.Size.Height - pictureBox1.ClientSize.Height) > 0)
   {
      this.vScrollBar1.Maximum = this.pictureBox1.Image.Size.Height - pictureBox1.ClientSize.Height;
   }
   /* If the HScrollBar is visible, adjust the Maximum of the 
      VSCrollBar to account for the width of the HScrollBar.*/
   if(this.hScrollBar1.Visible)
   {
      this.vScrollBar1.Maximum += this.hScrollBar1.Height;
   }
   this.vScrollBar1.LargeChange = this.vScrollBar1.Maximum / 10;
   this.vScrollBar1.SmallChange = this.vScrollBar1.Maximum / 20;
   // Adjust the Maximum value to make the raw Maximum value attainable by user interaction.
   this.vScrollBar1.Maximum += this.vScrollBar1.LargeChange;
}
void SetScrollBarValues()
{
   // Set the Maximum, Minimum, LargeChange and SmallChange properties.
   this->vScrollBar1->Minimum = 0;
   this->hScrollBar1->Minimum = 0;

   // If the offset does not make the Maximum less than zero, set its value. 
   if ( (this->pictureBox1->Image->Size.Width - pictureBox1->ClientSize.Width) > 0 )
   {
      this->hScrollBar1->Maximum = this->pictureBox1->Image->Size.Width - pictureBox1->ClientSize.Width;
   }

   /* If the VScrollBar is visible, adjust the Maximum of the 
         HSCrollBar to account for the width of the VScrollBar. */
   if ( this->vScrollBar1->Visible )
   {
      this->hScrollBar1->Maximum += this->vScrollBar1->Width;
   }

   this->hScrollBar1->LargeChange = this->hScrollBar1->Maximum / 10;
   this->hScrollBar1->SmallChange = this->hScrollBar1->Maximum / 20;

   // Adjust the Maximum value to make the raw Maximum value attainable by user interaction.
   this->hScrollBar1->Maximum += this->hScrollBar1->LargeChange;

   // If the offset does not make the Maximum less than zero, set its value.    
   if ( (this->pictureBox1->Image->Size.Height - pictureBox1->ClientSize.Height) > 0 )
   {
      this->vScrollBar1->Maximum = this->pictureBox1->Image->Size.Height - pictureBox1->ClientSize.Height;
   }

   /* If the HScrollBar is visible, adjust the Maximum of the 
         VSCrollBar to account for the width of the HScrollBar.*/
   if ( this->hScrollBar1->Visible )
   {
      this->vScrollBar1->Maximum += this->hScrollBar1->Height;
   }

   this->vScrollBar1->LargeChange = this->vScrollBar1->Maximum / 10;
   this->vScrollBar1->SmallChange = this->vScrollBar1->Maximum / 20;
   
   // Adjust the Maximum value to make the raw Maximum value attainable by user interaction.
   this->vScrollBar1->Maximum += this->vScrollBar1->LargeChange;
}
public void SetScrollBarValues()
{
    // Set the Maximum, Minimum, LargeChange and SmallChange properties.
    this.vScrollBar1.set_Minimum(0);
    this.hScrollBar1.set_Minimum(0);

    // If the offset does not make the Maximum less than zero, 
    // set its value. 
    if (this.pictureBox1.get_Image().get_Size().get_Width() 
        - pictureBox1.get_ClientSize().get_Width() > 0) {
            this.hScrollBar1.set_Maximum(
                this.pictureBox1.get_Image().get_Size().get_Width() 
                - pictureBox1.get_ClientSize().get_Width());
    }

    /* If the VScrollBar is visible, adjust the Maximum of the 
       HSCrollBar to account for the width of the VScrollBar. 
     */
    if (this.vScrollBar1.get_Visible()) {
        this.hScrollBar1.set_Maximum(
            this.hScrollBar1.get_Maximum() + this.vScrollBar1.get_Width());
    }

    this.hScrollBar1.set_LargeChange(this.hScrollBar1.get_Maximum() / 10);
    this.hScrollBar1.set_SmallChange(this.hScrollBar1.get_Maximum() / 20);

    // Adjust the Maximum value to make the raw Maximum value attainable 
    // by user interaction.
    this.hScrollBar1.set_Maximum(
        this.hScrollBar1.get_Maximum() 
        + this.hScrollBar1.get_LargeChange());

    // If the offset does not make the Maximum less than zero, 
    // set its value.    
    if (this.pictureBox1.get_Image().get_Size().get_Height() 
        - pictureBox1.get_ClientSize().get_Height() > 0) {
            this.vScrollBar1.set_Maximum(
                this.pictureBox1.get_Image().get_Size().get_Height() 
                - pictureBox1.get_ClientSize().get_Height());
    }

    /* If the HScrollBar is visible, adjust the Maximum of the 
       VSCrollBar to account for the width of the HScrollBar.
     */
    if (this.hScrollBar1.get_Visible()) {
        this.vScrollBar1.set_Maximum(this.vScrollBar1.get_Maximum() 
            + this.hScrollBar1.get_Height());
    }

    this.vScrollBar1.set_LargeChange(this.vScrollBar1.get_Maximum() / 10);
    this.vScrollBar1.set_SmallChange(this.vScrollBar1.get_Maximum() / 20);

    // Adjust the Maximum value to make the raw Maximum value attainable 
    // by user interaction.
    this.vScrollBar1.set_Maximum(
        this.vScrollBar1.get_Maximum() 
        + this.vScrollBar1.get_LargeChange());
} //SetScrollBarValues

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

ScrollBar-Klasse
ScrollBar-Member
System.Windows.Forms-Namespace
ScrollBar.LargeChange-Eigenschaft