ScrollEventArgs Classe

Definição

Fornece dados para o Scroll evento.

public ref class ScrollEventArgs : EventArgs
[System.Runtime.InteropServices.ComVisible(true)]
public class ScrollEventArgs : EventArgs
[<System.Runtime.InteropServices.ComVisible(true)>]
type ScrollEventArgs = class
    inherit EventArgs
Public Class ScrollEventArgs
Inherits EventArgs
Herança
ScrollEventArgs
Atributos

Exemplos

O seguinte exemplo de código demonstra a utilização deste elemento.

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

Observações

O Scroll evento ocorre quando o utilizador altera o valor da barra de deslocamento. Este evento pode resultar de várias ações, como clicar numa seta da barra de deslocamento, pressionar a SETA PARA CIMA ou SETA PARA BAIXO, ou arrastar a caixa de deslocamento. Especifica ScrollEventArgs o tipo de evento de scroll que ocorreu e o novo valor da barra de scroll. Use a ScrollOrientation propriedade para determinar a orientação da barra de deslocamento do Scroll evento.

O Scroll evento ocorre para os DataGridView, ScrollableControl, ScrollBar, e DataGrid controlos.

Construtores

Name Description
ScrollEventArgs(ScrollEventType, Int32, Int32, ScrollOrientation)

Inicializa uma nova instância da ScrollEventArgs classe usando os valores dados para as Typepropriedades , OldValue, NewValue, e ScrollOrientation .

ScrollEventArgs(ScrollEventType, Int32, Int32)

Inicializa uma nova instância da ScrollEventArgs classe usando os valores dados para as Typepropriedades , OldValue, e NewValue .

ScrollEventArgs(ScrollEventType, Int32, ScrollOrientation)

Inicializa uma nova instância da ScrollEventArgs classe usando os valores dados para as Typepropriedades , NewValue, e ScrollOrientation .

ScrollEventArgs(ScrollEventType, Int32)

Inicializa uma nova instância da ScrollEventArgs classe usando os valores dados para as Type propriedades e.NewValue

Propriedades

Name Description
NewValue

Recebe ou define o novo Value da barra de deslocamento.

OldValue

Fica com o velho Value da barra de scroll.

ScrollOrientation

Obtém a orientação da barra de scroll que elevou o Scroll evento.

Type

Obtém o tipo de evento de pergaminho que ocorreu.

Métodos

Name Description
Equals(Object)

Determina se o objeto especificado é igual ao objeto atual.

(Herdado de Object)
GetHashCode()

Serve como função de hash predefinida.

(Herdado de Object)
GetType()

Obtém o Type da instância atual.

(Herdado de Object)
MemberwiseClone()

Cria uma cópia superficial do atual Object.

(Herdado de Object)
ToString()

Devolve uma cadeia que representa o objeto atual.

(Herdado de Object)

Aplica-se a

Ver também