Dieser Artikel wurde maschinell übersetzt. Wenn Sie die englische Version des Artikels anzeigen möchten, aktivieren Sie das Kontrollkästchen Englisch. Sie können den englischen Text auch in einem Popupfenster anzeigen, indem Sie den Mauszeiger über den Text bewegen.
Übersetzung
Englisch

Shape.OnPaint-Methode: (PaintEventArgs)

 

Veröffentlicht: Oktober 2016

Löst das Paint-Ereignis aus.

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

protected internal virtual void OnPaint(
	PaintEventArgs e
)

Parameter

e
Type: System.Windows.Forms.PaintEventArgs

Ein T:System.PaintEventArgs, das die Ereignisdaten enthält.

Raising an event invokes the event handler through a delegate. For more information, see Handling and Raising Events.

The OnPaint 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.

Hinweise für Vererber:

When you override OnPaint in a derived class, be sure to call the OnPaint method of the base class so that registered delegates receive the event.

The following example is a method that is executed when the E:Microsoft.VisualBasic.PowerPacks.Shape.Click event occurs. The T:Microsoft.VisualBasic.PowerPacks.Shape class has several methods with the name pattern OnEventName that execute methods when the EventName event occurs. (EventName represents the name of the corresponding event.)

The following example demonstrates how to override the M:Microsoft.VisualBasic.PowerPacks.Shape.OnClick(System.EventArgs) and M:Microsoft.VisualBasic.PowerPacks.Shape.OnLostFocus(System.EventArgs) methods in a class that derives from T:Microsoft.VisualBasic.PowerPacks.LineShape.

public class HighlightLine :
    LineShape
{
    protected override void OnClick(EventArgs e)
    {
        // Change the color of the line when clicked.
        this.BorderColor = Color.Red;
        base.OnClick(e);
    }
    protected override void OnLostFocus(System.EventArgs e)
    {
        // Change the color of the line when focus is changed.
        this.BorderColor = Color.Black;
        base.OnLostFocus(e);
    }
}
Zurück zum Anfang
Anzeigen: