Export (0) Print
Expand All

HScrollBar Class

Represents a standard Windows horizontal scroll bar.

For a list of all members of this type, see HScrollBar Members.

System.Object
   System.MarshalByRefObject
      System.ComponentModel.Component
         System.Windows.Forms.Control
            System.Windows.Forms.ScrollBar
               System.Windows.Forms.HScrollBar

[Visual Basic]
Public Class HScrollBar
   Inherits ScrollBar
[C#]
public class HScrollBar : ScrollBar
[C++]
public __gc class HScrollBar : public ScrollBar
[JScript]
public class HScrollBar extends ScrollBar

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Remarks

Most controls that need scroll bars already provide them and do not require this control. This is true of a multiline TextBox control, a ListBox, and a ComboBox, for example.

You can use this control to implement scrolling in containers that do not provide their own scroll bars such as a PictureBox or for user input of numeric data. The numeric data can be displayed in a control or used in code. The Minimum and Maximum properties determine the range of values the user can select. The LargeChange property determines the effect of clicking within the scroll bar but outside the scroll box. The SmallChange property determines the effect of clicking the scroll arrows at each end of the control.

Example

The following example creates and initializes an HScrollBar and adds it to a Form.

[Visual Basic] 
Private Sub InitializeMyScrollBar()
    ' Create and initialize an HScrollBar.
    Dim hScrollBar1 As New HScrollBar()
    
    ' Dock the scroll bar to the bottom of the form.
    hScrollBar1.Dock = DockStyle.Bottom
    
    ' Add the scroll bar to the form.
    Controls.Add(hScrollBar1)
End Sub 'InitializeMyScrollBar

[C#] 
private void InitializeMyScrollBar()
 {
    // Create and initialize an HScrollBar.
    HScrollBar hScrollBar1 = new HScrollBar();
    
    // Dock the scroll bar to the bottom of the form.
    hScrollBar1.Dock = DockStyle.Bottom;
    
    // Add the scroll bar to the form.
    Controls.Add(hScrollBar1);
 }
    

[C++] 
private:
    void InitializeMyScrollBar() {
        // Create and initialize an HScrollBar.
        HScrollBar __gc *hScrollBar1 = new HScrollBar();
    
        // Dock the scroll bar to the bottom of the form.
        hScrollBar1->Dock = DockStyle::Bottom;
    
        // Add the scroll bar to the form.
        Controls->Add(hScrollBar1);
    };
    

[JScript] 
function InitializeMyScrollBar(){
    // Create and initialize an HScrollBar.
    var hScrollBar1 : HScrollBar = new HScrollBar()
    
    // Dock the scroll bar to the bottom of the form.
    hScrollBar1.Dock = DockStyle.Bottom
    
    // Add the scroll bar to the form.
    Controls.Add(hScrollBar1)
}

Requirements

Namespace: System.Windows.Forms

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

Assembly: System.Windows.Forms (in System.Windows.Forms.dll)

See Also

HScrollBar Members | System.Windows.Forms Namespace | ScrollBar | VScrollBar

Show:
© 2014 Microsoft