ScrollEventArgs 類別

定義

提供 Scroll 事件的資料。

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
繼承
ScrollEventArgs
屬性

範例

下列程式碼範例示範此成員的使用。

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 事件。 此事件可能會因各種動作而產生,例如按一下捲軸箭號、按向上鍵或向下箭號,或拖曳捲動方塊。 ScrollEventArgs會指定發生的滾動事件種類,以及捲軸的新值。 ScrollOrientation使用 屬性來判斷事件的捲軸方向 Scroll

、、 ScrollBarDataGrid 控制項會發生 DataGridViewScrollableControlScroll 事件。

建構函式

ScrollEventArgs(ScrollEventType, Int32)

使用 ScrollEventArgsType 屬性的給定值,初始化 NewValue 類別的新執行個體。

ScrollEventArgs(ScrollEventType, Int32, Int32)

使用 ScrollEventArgsTypeOldValue 屬性的給定值,初始化 NewValue 類別的新執行個體。

ScrollEventArgs(ScrollEventType, Int32, Int32, ScrollOrientation)

使用 ScrollEventArgsTypeOldValueNewValue 屬性的給定值,初始化 ScrollOrientation 類別的新執行個體。

ScrollEventArgs(ScrollEventType, Int32, ScrollOrientation)

使用 ScrollEventArgsTypeNewValue 屬性的給定值,初始化 ScrollOrientation 類別的新執行個體。

屬性

NewValue

取得或設定捲軸的新 Value

OldValue

取得捲軸舊的 Value

ScrollOrientation

取得引發 Scroll 事件的捲軸方向。

Type

取得發生的捲動事件型別。

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於

另請參閱