ScrollEventHandler Delegate
.NET Framework (current version)
Represents the method that handles the Scroll event of a DataGridView, ScrollBar, TrackBar, or DataGrid.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Parameters
- sender
-
Type:
System::Object^
The source of the event.
- e
-
Type:
System.Windows.Forms::ScrollEventArgs^
A ScrollEventArgs that contains the event data.
When you create a ScrollEventArgs delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see NIB: Events and Delegates.
The following code example demonstrates the use of this type.
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; } }
.NET Framework
Available since 1.1
Available since 1.1
Show: