ScrollEventArgs ScrollEventArgs ScrollEventArgs ScrollEventArgs Class

定义

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
继承
ScrollEventArgsScrollEventArgsScrollEventArgsScrollEventArgs
属性

示例

下面的代码示例演示如何将此成员。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发生事件DataGridViewScrollableControlScrollBar,和DataGrid控件。The Scroll event occurs for the DataGridView, ScrollableControl, ScrollBar, and DataGrid controls.

构造函数

ScrollEventArgs(ScrollEventType, Int32) ScrollEventArgs(ScrollEventType, Int32) ScrollEventArgs(ScrollEventType, Int32) ScrollEventArgs(ScrollEventType, Int32)

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

ScrollEventArgs(ScrollEventType, Int32, Int32) ScrollEventArgs(ScrollEventType, Int32, Int32) ScrollEventArgs(ScrollEventType, Int32, Int32) ScrollEventArgs(ScrollEventType, Int32, Int32)

初始化的新实例ScrollEventArgs类使用的给定的值TypeOldValue,和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) ScrollEventArgs(ScrollEventType, Int32, Int32, ScrollOrientation) ScrollEventArgs(ScrollEventType, Int32, Int32, ScrollOrientation) ScrollEventArgs(ScrollEventType, Int32, Int32, ScrollOrientation)

初始化的新实例ScrollEventArgs类使用的给定的值TypeOldValueNewValue,和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) ScrollEventArgs(ScrollEventType, Int32, ScrollOrientation) ScrollEventArgs(ScrollEventType, Int32, ScrollOrientation) ScrollEventArgs(ScrollEventType, Int32, ScrollOrientation)

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

属性

NewValue NewValue NewValue NewValue

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

OldValue OldValue OldValue OldValue

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

ScrollOrientation ScrollOrientation ScrollOrientation ScrollOrientation

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

Type Type Type Type

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

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

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

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

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

(Inherited from Object)
GetType() GetType() GetType() GetType()

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

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

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

(Inherited from Object)
ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)

适用于

另请参阅