다음을 통해 공유


Control.KeyUp 이벤트

컨트롤에 포커스가 있을 때 키를 눌렀다 놓으면 발생합니다.

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
Public Event KeyUp As KeyEventHandler
‘사용 방법
Dim instance As Control
Dim handler As KeyEventHandler

AddHandler instance.KeyUp, handler
public event KeyEventHandler KeyUp
public:
event KeyEventHandler^ KeyUp {
    void add (KeyEventHandler^ value);
    void remove (KeyEventHandler^ value);
}
/** @event */
public void add_KeyUp (KeyEventHandler value)

/** @event */
public void remove_KeyUp (KeyEventHandler value)
JScript에서는 이벤트를 사용할 수 있지만 새로 선언할 수는 없습니다.

설명

키 이벤트는 다음 순서대로 발생합니다.

  1. KeyDown

  2. KeyPress

  3. KeyUp

폼 수준에서만 키보드 이벤트를 처리하고 다른 컨트롤에서는 키보드 이벤트를 받지 않도록 하려면 해당 폼의 KeyPress 이벤트 처리 메서드에 있는 KeyPressEventArgs.Handled 속성을 true로 설정합니다. Tab, Enter, Esc 및 화살표 키 같은 일부 키는 컨트롤에 의해 자동으로 처리됩니다. 이러한 키를 눌렀을 때 KeyUp 이벤트가 발생하게 하려면 폼의 각 컨트롤에서 IsInputKey 메서드를 재정의해야 합니다. IsInputKey 재정의를 위한 코드에서는 특수 키 중 하나를 눌렀을 때 true 값이 반환되는지를 확인해야 합니다.

이벤트 처리에 대한 자세한 내용은 이벤트 사용을 참조하십시오.

예제

다음 코드 예제에서는 Help 클래스에 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 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

플랫폼

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

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

Control 클래스
Control 멤버
System.Windows.Forms 네임스페이스
OnKeyUp
Control.KeyDown 이벤트
Control.KeyPress 이벤트