ScrollBar.Minimum 属性
获取或设置可滚动范围的值的下限。
**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)
语法
声明
Public Property Minimum As Integer
用法
Dim instance As ScrollBar
Dim value As Integer
value = instance.Minimum
instance.Minimum = value
public int Minimum { get; set; }
public:
property int Minimum {
int get ();
void set (int value);
}
/** @property */
public int get_Minimum ()
/** @property */
public void set_Minimum (int value)
public function get Minimum () : int
public function set Minimum (value : int)
属性值
一个数值。默认值为 0。
示例
下面的示例使用派生类 VScrollBar 和 HScrollBar,并设置它们的一些公共属性。它们的 Maximum 属性设置为等于分配给其父级 (PictureBox) 的 Image 的 Height 或 Width。LargeChange 属性设置为等于图片框的大小(减去滚动条的高度或宽度)。SmallChange 属性设置为等于 LargeChange 属性值除以 5。最后,两个滚动条的 Value 属性值被设置为 0。结果为在某个图片框上所显示的水平和垂直滚动条,该图片框显示 Image 的左上角。滚动条的滚动将不会超过图像的末端,并且当 LargeChange 滚动发生时,图像移动的距离仅等于在图片框中显示的区域。滚动 LargeChange 一次所移动的距离相当于滚动 SmallChange 五次所移动的距离。此代码假定已经在 Form 上创建了一个 PictureBox、一个 HScrollBar、一个 VScrollBar 和一个 Image。它还假定已添加对 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 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求。
版本信息
.NET Framework
受以下版本支持:2.0、1.1、1.0
.NET Compact Framework
受以下版本支持:2.0、1.0
请参见
参考
ScrollBar 类
ScrollBar 成员
System.Windows.Forms 命名空间
ScrollBar.Maximum 属性