ScrollEventArgs 类

定义

Scroll 事件提供数据。Provides data for the Scroll event.

public ref class ScrollEventArgs : EventArgs
[System.Runtime.InteropServices.ComVisible(true)]
public class ScrollEventArgs : EventArgs
type ScrollEventArgs = class
    inherit EventArgs
Public Class ScrollEventArgs
Inherits EventArgs
继承
ScrollEventArgs
属性

示例

下面的代码示例演示如何使用此成员。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

注解

当用户更改滚动条的值时发生 Scroll 事件。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. ScrollEventArgs 指定发生的滚动事件的类型和滚动条的新值。The ScrollEventArgs specifies the type of scroll event that occurred and the new value of the scroll bar. 使用 ScrollOrientation 属性可确定 Scroll 事件的滚动条方向。Use the ScrollOrientation property to determine the scroll bar orientation for the Scroll event.

Scroll 事件发生于 DataGridViewScrollableControlScrollBarDataGrid 控件。The Scroll event occurs for the DataGridView, ScrollableControl, ScrollBar, and DataGrid controls.

构造函数

ScrollEventArgs(ScrollEventType, Int32)

使用 ScrollEventArgsType 属性的给定值初始化 NewValue 类的新实例。Initializes a new instance of the ScrollEventArgs class using the given values for the Type and NewValue properties.

ScrollEventArgs(ScrollEventType, Int32, Int32)

使用 ScrollEventArgsTypeOldValue 属性的给定值初始化 NewValue 类的新实例。Initializes a new instance of the ScrollEventArgs class using the given values for the Type, OldValue, and NewValue properties.

ScrollEventArgs(ScrollEventType, Int32, Int32, ScrollOrientation)

使用 ScrollEventArgsTypeOldValueNewValue 属性的给定值初始化 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)

使用 ScrollEventArgsTypeNewValue 属性的给定值初始化 ScrollOrientation 类的新实例。Initializes a new instance of the ScrollEventArgs class using the given values for the Type, NewValue, and ScrollOrientation properties.

属性

NewValue

获取或设置滚动条的新 ValueGets or sets the new Value of the scroll bar.

OldValue

获取滚动条的旧 Value 值。Gets the old Value of the scroll bar.

ScrollOrientation

获取引发 Scroll 事件的滚动条方向。Gets the scroll bar orientation that raised the Scroll event.

Type

获取所发生的滚动事件的类型。Gets the type of scroll event that occurred.

方法

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

适用于

另请参阅