この記事は翻訳者によって翻訳されたものです。 記事の文章にポインターを重ねると、原文のテキストが表示されます。 |
訳文
原文
|
Control.KeyUp イベント
.NET Framework 4
コントロールにフォーカスがあるときにキーが離されると発生します。
アセンブリ: System.Windows.Forms (System.Windows.Forms.dll 内)
キー イベントは次の順序で発生します。
キーボード イベントをフォームでだけ処理し、そのイベントを他のコントロールでは受け取らないようにする場合は、フォームの KeyPress イベント処理メソッドの KeyPressEventArgs.Handled プロパティを true に設定します。 Tab キー、Return キー、Esc キー、方向キーなどは、コントロールによって自動処理されます。 これらのキーで KeyUp イベントを発生させるには、フォーム上の各コントロールで IsInputKey メソッドをオーバーライドする必要があります。 IsInputKey のオーバーライドのコードは、特殊なキーのいずれかが押され、そのキーが true の値を返したかどうかを判断する必要があります。
イベント処理の詳細については、「イベントの利用」を参照してください。
KeyUp イベントと Help クラスを使用して、ポップアップ スタイルのヘルプをユーザーに表示するコード例を次に示します。
// 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)); } }
Windows 7, Windows Vista SP1 以降, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core はサポート対象外), Windows Server 2008 R2 (SP1 以降で Server Core をサポート), Windows Server 2003 SP2
.NET Framework では、各プラットフォームのすべてのバージョンはサポートしていません。 サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。