Freigeben über


Control.OnKeyUp-Methode

Löst das KeyUp-Ereignis aus.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
Protected Overridable Sub OnKeyUp ( _
    e As KeyEventArgs _
)
'Usage
Dim e As KeyEventArgs

Me.OnKeyUp(e)
protected virtual void OnKeyUp (
    KeyEventArgs e
)
protected:
virtual void OnKeyUp (
    KeyEventArgs^ e
)
protected void OnKeyUp (
    KeyEventArgs e
)
protected function OnKeyUp (
    e : KeyEventArgs
)

Parameter

  • e
    Eine Instanz von KeyEventArgs, die die Ereignisdaten enthält.

Hinweise

Durch das Auslösen eines Ereignisses wird der Ereignishandler über einen Delegaten aufgerufen. Weitere Informationen finden Sie unter Auslösen eines Ereignisses.

Die OnKeyUp-Methode ermöglicht es auch abgeleiteten Klassen, das Ereignis ohne Anfügen eines Delegaten zu behandeln. Dies ist das bevorzugte Verfahren für die Behandlung des Ereignisses in einer abgeleiteten Klasse.

Hinweise für Erben Wenn Sie OnKeyUp in einer abgeleiteten Klasse überschreiben, müssen Sie die OnKeyUp-Methode der Basisklasse aufrufen, sodass registrierte Delegaten das Ereignis empfangen.

Beispiel

Im folgenden Codebeispiel wird das KeyUp-Ereignis mit der Help-Klasse verwendet, um dem Benutzer die Hilfe als Popup anzuzeigen.

' This example demonstrates how to use the KeyUp event with the Help class to display
' pop-up style help to the user of the application. When the user presses F1, the Help
' class displays a pop-up window, similar to a ToolTip, near the control. This example assumes
' that a TextBox control, named textBox1, has been added to the form and its KeyUp
' event has been contected to this event handler method.
Private Sub textBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles textBox1.KeyUp
    ' Determine whether the key entered is the F1 key. Display help if it is.
    If e.KeyCode = Keys.F1 Then
        ' Display a pop-up help topic to assist the user.
        Help.ShowPopup(textBox1, "Enter your first name", New Point(textBox1.Right, Me.textBox1.Bottom))
    End If
End Sub 'textBox1_KeyUp
// This example demonstrates how to use the KeyUp event with the Help class to display
// pop-up style help to the user of the application. When the user presses F1, the Help
// class displays a pop-up window, similar to a ToolTip, near the control. This example assumes
// that a TextBox control, named textBox1, has been added to the form and its KeyUp
// event has been contected to this event handler method.
private void textBox1_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
{
    // Determine whether the key entered is the F1 key. Display help if it is.
    if(e.KeyCode == Keys.F1)
    {
        // Display a pop-up help topic to assist the user.
        Help.ShowPopup(textBox1, "Enter your first name", new Point(textBox1.Right, this.textBox1.Bottom));
    }
}
   // This example demonstrates how to use the KeyUp event with the Help class to display
   // pop-up style help to the user of the application. When the user presses F1, the Help
   // class displays a pop-up window, similar to a ToolTip, near the control. This example assumes
   // that a TextBox control, named textBox1, has been added to the form and its KeyUp
   // event has been connected to this event handler method.
private:
   void textBox1_KeyUp( Object^ /*sender*/, System::Windows::Forms::KeyEventArgs^ e )
   {
      
      // Determine whether the key entered is the F1 key. Display help if it is.
      if ( e->KeyCode == Keys::F1 )
      {
         
         // Display a pop-up help topic to assist the user.
         Help::ShowPopup( textBox1, "Enter your first name", Point(textBox1->Right,this->textBox1->Bottom) );
      }
   }
// This example demonstrates how to use the KeyUp event with the Help 
// class to display pop-up style help to the user of the application. 
// When the user presses F1, the Help class displays a pop-up window, 
// similar to a ToolTip, near the control. This example assumes that a 
// TextBox control, named textBox1, has been added to the form and its 
// KeyUp event has been contected to this event handler method.
private void textBox1_KeyUp(Object sender, 
    System.Windows.Forms.KeyEventArgs e)
{
    // Determine whether the key entered is the F1 key. 
    // Display help if it is.
    if (e.get_KeyCode().Equals(Keys.F1)) {
        // Display a pop-up help topic to assist the user.
        Help.ShowPopup(textBox1, "Enter your first name", 
            new Point(textBox1.get_Right(), this.textBox1.get_Bottom()));
    }
} //textBox1_KeyUp

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

Control-Klasse
Control-Member
System.Windows.Forms-Namespace
KeyUp