ScrollBar.SmallChange プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Dim instance As ScrollBar Dim value As Integer value = instance.SmallChange instance.SmallChange = value
/** @property */ public int get_SmallChange () /** @property */ public void set_SmallChange (int value)
数値。既定値は、1 です。


ユーザーが方向キーの 1 つを押すと、またはスクロール バー ボタンの 1 つをクリックすると、Value プロパティは SmallChange プロパティに設定されている値に従って変更されます。
SmallChange 値には、Height (垂直方向のスクロール バーの場合) または Width (水平方向のスクロール バーの場合) の値に対する倍率を設定できます。このように設定すると、スクロール バーのサイズに対するスクロール バーの移動距離の比率が保たれます。

派生クラス VScrollBar と HScrollBar を使用して、これらのクラスの共通プロパティの一部を設定するコード例を次に示します。これらの Maximum プロパティは、親である PictureBox に割り当てられている Image の Height および Width と等しくなるように設定されます。LargeChange プロパティは、ピクチャ ボックスのサイズからスクロール バーの高さまたは幅を引いたサイズに設定されます。SmallChange プロパティは、LargeChange プロパティの値を 5 で割った値に設定されます。最後に、両方のスクロール バーの Value プロパティの値が 0 に設定されます。この結果、Image の左上隅を表示するピクチャ ボックスに、垂直スクロール バーと水平スクロール バーが表示されます。スクロール バーは、イメージの範囲を越えてスクロールすることはありません。LargeChange が実行された場合、イメージは、ピクチャ ボックスに表示された領域と同じ距離だけ移動します。5 回の SmallChange スクロールで、1 回の LargeChange スクロールと同じ距離だけ移動します。このコードは、PictureBox、HScrollBar、VScrollBar、および Image が Form 上ですべて作成されていることを前提にしています。この例は、System.Drawing 名前空間への参照が追加されていることも前提にしています。この例を拡張するための追加コードについては、ScrollBar クラス概要のトピックを参照してください。
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

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- ScrollBar.SmallChange プロパティのページへのリンク