ScrollEventArgs (Clase)
Actualización: noviembre 2007
Proporciona datos del evento Scroll.
Ensamblado: System.Windows.Forms (en System.Windows.Forms.dll)
El evento Scroll tiene lugar cuando el usuario cambia el valor de la barra de desplazamiento. Este evento puede producirse como consecuencia de diversas acciones, como hacer clic en una flecha de barra de desplazamiento, presionar FLECHA ARRIBA o FLECHA ABAJO, o arrastrar el cuadro de desplazamiento. ScrollEventArgs especifica el tipo de evento de desplazamiento que tuvo lugar y el nuevo valor de la barra de desplazamiento. Utilice la propiedad ScrollOrientation para determinar la orientación de la barra de desplazamiento para el evento Scroll.
El evento Scroll se genera para los controles DataGridView, ScrollableControl, ScrollBar y DataGrid.
En el ejemplo de código siguiente se muestra el uso de este miembro.
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 void AddMyScrollEventHandlers()
{
// Create and initialize a VScrollBar.
VScrollBar vScrollBar1 = new VScrollBar();
// Add event handlers for the OnScroll and OnValueChanged events.
vScrollBar1.add_Scroll(
new ScrollEventHandler(this.vScrollBar1_Scroll));
vScrollBar1.add_ValueChanged(
new EventHandler(this.vScrollBar1_ValueChanged));
} //AddMyScrollEventHandlers
// Create the ValueChanged event handler.
private void vScrollBar1_ValueChanged(Object sender, EventArgs e)
{
// Display the new value in the label.
label1.set_Text("vScrollBar Value:(OnValueChanged Event) "
+ vScrollBar1.get_Value());
} //vScrollBar1_ValueChanged
// Create the Scroll event handler.
private void vScrollBar1_Scroll(Object sender, ScrollEventArgs e)
{
// Display the new value in the label.
label1.set_Text(
"VScrollBar Value:(OnScroll Event) " + e.get_NewValue());
} //vScrollBar1_Scroll
private void button1_Click(Object sender, EventArgs e)
{
// Add 40 to the Value property if it will not exceed the Maximum
// value.
if (vScrollBar1.get_Value() + 40 < vScrollBar1.get_Maximum()) {
vScrollBar1.set_Value(vScrollBar1.get_Value() + 40);
}
} //button1_Click
Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
.NET Framework y .NET Compact Framework no admiten todas las versiones de cada plataforma. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.