ScrollEventArgs Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Provides data for the Scroll
event.
public ref class ScrollEventArgs : EventArgs
[System.Runtime.InteropServices.ComVisible(true)]
public class ScrollEventArgs : EventArgs
public class ScrollEventArgs : EventArgs
[<System.Runtime.InteropServices.ComVisible(true)>]
type ScrollEventArgs = class
inherit EventArgs
type ScrollEventArgs = class
inherit EventArgs
Public Class ScrollEventArgs
Inherits EventArgs
- Inheritance
- Attributes
Examples
The following code example demonstrates the use of this member.
void AddMyScrollEventHandlers()
{
// Create and initialize a VScrollBar.
VScrollBar^ vScrollBar1 = gcnew VScrollBar;
// Add event handlers for the OnScroll and OnValueChanged events.
vScrollBar1->Scroll += gcnew ScrollEventHandler( this, &Form1::vScrollBar1_Scroll );
vScrollBar1->ValueChanged += gcnew EventHandler( this, &Form1::vScrollBar1_ValueChanged );
}
// Create the ValueChanged event handler.
void vScrollBar1_ValueChanged( Object^ /*sender*/, EventArgs^ /*e*/ )
{
// Display the new value in the label.
label1->Text = String::Format( "vScrollBar Value:(OnValueChanged Event) {0}", vScrollBar1->Value );
}
// Create the Scroll event handler.
void vScrollBar1_Scroll( Object^ /*sender*/, ScrollEventArgs^ e )
{
// Display the new value in the label.
label1->Text = String::Format( "VScrollBar Value:(OnScroll Event) {0}", e->NewValue );
}
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;
}
}
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;
}
}
Private Sub AddMyScrollEventHandlers()
' Create and initialize a VScrollBar.
Dim vScrollBar1 As New VScrollBar()
' Add event handlers for the OnScroll and OnValueChanged events.
AddHandler vScrollBar1.Scroll, AddressOf Me.vScrollBar1_Scroll
AddHandler vScrollBar1.ValueChanged, AddressOf Me.vScrollBar1_ValueChanged
End Sub
' Create the ValueChanged event handler.
Private Sub vScrollBar1_ValueChanged(sender As Object, e As EventArgs)
' Display the new value in the label.
label1.Text = "vScrollBar Value:(OnValueChanged Event) " & _
vScrollBar1.Value.ToString()
End Sub
' Create the Scroll event handler.
Private Sub vScrollBar1_Scroll(sender As Object, e As ScrollEventArgs)
' Display the new value in the label.
label1.Text = "VScrollBar Value:(OnScroll Event) " & _
e.NewValue.ToString()
End Sub
Private Sub button1_Click(sender As Object, e As EventArgs)
' Add 40 to the Value property if it will not exceed the Maximum value.
If vScrollBar1.Value + 40 < vScrollBar1.Maximum Then
vScrollBar1.Value = vScrollBar1.Value + 40
End If
End Sub
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) |
Initializes a new instance of the ScrollEventArgs class using the given values for the Type and NewValue 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, 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, ScrollOrientation) |
Initializes a new instance of the ScrollEventArgs class using the given values for the Type, NewValue, and ScrollOrientation 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 |
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) |