ScrollBar.OnValueChanged Method

Raises the ValueChanged event.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

abstract OnValueChanged : 
        e:EventArgs -> unit  
override OnValueChanged : 
        e:EventArgs -> unit

Parameters

e
Type: System.EventArgs

An EventArgs that contains the event data.

Raising an event invokes the event handler through a delegate. For more information, see Raising an Event.

The OnValueChanged method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.

Notes to Inheritors

When overriding OnValueChanged in a derived class, be sure to call the base class’s OnValueChanged method so that registered delegates receive the event.

The following code example uses the derived class VScrollBar. Event handlers for the Scroll and ValueChanged events are created. This code assumes that a Label and Button have been created on a form and that the button has an event handler for the Click event. When the button is clicked, the Value property of the scroll bar is adjusted in code. The label will display the current value of the Value property and the event that changed it. You will notice that when the scroll value is changed by the button's Click event, only the ValueChanged event is raised. In contrast, when the scroll bar is scrolled manually, the Scroll event is raised immediately after the ValueChanged event.

NoteNote

For instructions about how to run this example in Visual Studio, see How to: Compile and Run a Complete Windows Forms Code Example Using Visual Studio.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft