This documentation is archived and is not being maintained.

ScrollBar.Maximum Property

Gets or sets the upper limit of values of the scrollable range.

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

public int Maximum { get; set; }
/** @property */
public int get_Maximum ()

/** @property */
public void set_Maximum (int value)

public function get Maximum () : int

public function set Maximum (value : int)

Not applicable.

Property Value

A numeric value. The default value is 100.

You might consider adjusting the Maximum property dynamically to match the size of the scroll bar's parent in proportion to pixel size or to the number of rows or lines displayed.

The maximum value can only be reached programmatically. The value of a scroll bar cannot reach its maximum value through user interaction at run time. The maximum value that can be reached through user interaction is equal to 1 plus the Maximum property value minus the LargeChange property value. If necessary, you can set the Maximum property to the size of the object -1 to account for the term of 1.

The following example assumes that you have created a Form, added a PictureBox to the Form, and added a horizontal HScrollBar and a vertical VScrollBar to the PictureBox. This code example is part of a larger example provided for the ScrollBar class overview.

In this example, the Maximum property is set to the size of the Image plus the size of the scrollbar if it is visible plus an adjustment factor of the size of the LargeChange property.

You must add references to the System.Drawing and System.Windows.Forms namespaces to run this example.

NoteNote:

For instructions about how to run this example in Visual Studio, see How to: Compile and Run a Complete Windows Forms Code Example Using Visual Studio.

Windows 98, Windows Server 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

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0
Show: