Share via


Shape.OnCursorChanged Method

Raises the CursorChanged event.

Namespace:  Microsoft.VisualBasic.PowerPacks
Assembly:  Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)

Syntax

'Declaration
Protected Overridable Sub OnCursorChanged ( _
    e As EventArgs _
)
protected virtual void OnCursorChanged(
    EventArgs e
)
protected:
virtual void OnCursorChanged(
    EventArgs^ e
)
abstract OnCursorChanged : 
        e:EventArgs -> unit  
override OnCursorChanged : 
        e:EventArgs -> unit
protected function OnCursorChanged(
    e : EventArgs
)

Parameters

Remarks

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

The OnCursorChanged method also enables 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 you override OnCursorChanged in a derived class, be sure to call the OnCursorChanged method of the base class so that registered delegates receive the event.

Examples

The following example is an event-raising method that is executed when the Enabled property value changes. The Shape class has several methods with the name pattern OnPropertyNameChanged that raise the corresponding PropertyNameChanged event when the PropertyName value changes. (PropertyName represents the name of the corresponding property.)

The following example changes the color of a line when the Enabled property of a class derived from LineShape is changed to false.

Public Class DisabledLine
    Inherits LineShape
    Protected Overrides Sub OnEnabledChanged(ByVal e As EventArgs)
        ' Change the color of the line when selected. 
        If Me.BorderColor = SystemColors.InactiveBorder Then 
            Me.BorderColor = Color.Black
        Else 
            Me.BorderColor = SystemColors.InactiveBorder
        End If 
        MyBase.OnEnabledChanged(e)
    End Sub 
End Class
public class DisabledLine :
    LineShape
{
    protected override void OnEnabledChanged(EventArgs e)
    {
        // Change the color of the line when selected. 
        if (this.BorderColor == SystemColors.InactiveBorder)
        {
            this.BorderColor = Color.Black;
        }
        else
        {
            this.BorderColor = SystemColors.InactiveBorder;
        }
        base.OnEnabledChanged(e);
    }
}

.NET Framework Security

See Also

Reference

Shape Class

Microsoft.VisualBasic.PowerPacks Namespace

Other Resources

How to: Draw Lines with the LineShape Control (Visual Studio)

How to: Draw Shapes with the OvalShape and RectangleShape Controls (Visual Studio)

Introduction to the Line and Shape Controls (Visual Studio)