ScrollBar.Minimum 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定可捲動範圍的下限值。
public:
property int Minimum { int get(); void set(int value); };
public int Minimum { get; set; }
member this.Minimum : int with get, set
Public Property Minimum As Integer
屬性值
數值。 預設值為 0。
範例
下列範例假設您已建立 Form 、將 新增 PictureBox 至 Form ,並將水準 HScrollBar 和垂直 VScrollBar 新增至 PictureBox 。 此程式碼範例是類別概觀所提供較大範例的 ScrollBar 一部分。
在此範例中 Minimum ,屬性會設定為 0。
您必須新增 和 System.Windows.Forms 命名空間的 System.Drawing 參考,才能執行此範例。
注意
如需如何在 Visual Studio 中執行此範例的指示,請參閱如何:使用 Visual Studio 編譯和執行完整Windows Forms程式碼範例。
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