ScrollEventArgs Class

Definition

Provides data for the Scroll event.

[System.Runtime.InteropServices.ComVisible(true)]
public class ScrollEventArgs : EventArgs
public class ScrollEventArgs : EventArgs
Inheritance
ScrollEventArgs
Attributes

Examples

The following code example demonstrates the use of this member.

private void AddMyScrollEventHandlers()
 {
    // Create and initialize a VScrollBar.
    VScrollBar vScrollBar1 = new VScrollBar();
 
    // Add event handlers for the OnScroll and OnValueChanged events.
    vScrollBar1.Scroll += new ScrollEventHandler(
       this.vScrollBar1_Scroll);
    vScrollBar1.ValueChanged += new EventHandler(
       this.vScrollBar1_ValueChanged); 
 }
 
 // Create the ValueChanged event handler.
 private void vScrollBar1_ValueChanged(Object sender, 
                                       EventArgs e)
 {
     // Display the new value in the label.
     label1.Text = "vScrollBar Value:(OnValueChanged Event) " + vScrollBar1.Value.ToString();
 }
 
 // Create the Scroll event handler.
 private void vScrollBar1_Scroll(Object sender, 
                                 ScrollEventArgs e)
 {
     // Display the new value in the label.
     label1.Text = "VScrollBar Value:(OnScroll Event) " + e.NewValue.ToString();
 }
 
 private void button1_Click(Object sender, 
                           EventArgs e)
 {
    // Add 40 to the Value property if it will not exceed the Maximum value.
    if (vScrollBar1.Value + 40 < vScrollBar1.Maximum)
    {
        vScrollBar1.Value = vScrollBar1.Value + 40;
    }
 }

Remarks

The Scroll event occurs when the user changes the value of the scroll bar. This event can result from a variety of actions, such as clicking a scroll bar arrow, pressing the UP ARROW or DOWN ARROW, or dragging the scroll box. The ScrollEventArgs specifies the type of scroll event that occurred and the new value of the scroll bar. Use the ScrollOrientation property to determine the scroll bar orientation for the Scroll event.

The Scroll event occurs for the DataGridView, ScrollableControl, ScrollBar, and DataGrid controls.

Constructors

ScrollEventArgs(ScrollEventType, Int32, Int32, ScrollOrientation)

Initializes a new instance of the ScrollEventArgs class using the given values for the Type, OldValue, NewValue, and ScrollOrientation properties.

ScrollEventArgs(ScrollEventType, Int32, Int32)

Initializes a new instance of the ScrollEventArgs class using the given values for the Type, OldValue, and NewValue properties.

ScrollEventArgs(ScrollEventType, Int32, ScrollOrientation)

Initializes a new instance of the ScrollEventArgs class using the given values for the Type, NewValue, and ScrollOrientation properties.

ScrollEventArgs(ScrollEventType, Int32)

Initializes a new instance of the ScrollEventArgs class using the given values for the Type and NewValue properties.

Properties

NewValue

Gets or sets the new Value of the scroll bar.

OldValue

Gets the old Value of the scroll bar.

ScrollOrientation

Gets the scroll bar orientation that raised the Scroll event.

Type

Gets the type of scroll event that occurred.

Methods

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

Produto Versões
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

See also