Shape.KeyPress イベント
形状にフォーカスがあるときにキーが押されると発生します。
名前空間: Microsoft.VisualBasic.PowerPacks
アセンブリ: Microsoft.VisualBasic.PowerPacks.Vs (Microsoft.VisualBasic.PowerPacks.Vs.dll 内)
構文
'宣言
<BrowsableAttribute(True)> _
Public Event KeyPress As KeyPressEventHandler
[BrowsableAttribute(true)]
public event KeyPressEventHandler KeyPress
[BrowsableAttribute(true)]
public:
event KeyPressEventHandler^ KeyPress {
void add (KeyPressEventHandler^ value);
void remove (KeyPressEventHandler^ value);
}
[<BrowsableAttribute(true)>]
member KeyPress : IEvent<KeyPressEventHandler,
KeyPressEventArgs>
JScript では、イベントは使用できません。
解説
主要なイベントは、次の順序で発生します。
KeyPress
KeyPress非文字のキーではイベントは発生しません。ただしで、文字以外のキーは発生、KeyDownとKeyUpイベントです。
使用して、KeyCharプロパティを実行時に使用したり、一般的なキーボード操作のサブセットを変更するサンプルのキー入力します。
フォーム レベルでのみのキーボード イベントを処理し、キーボード イベントを受信する図形を有効に、次のように設定します。、HandledフォームのプロパティKeyPressイベント処理メソッドをtrueです。
イベントを処理する方法の詳細については、次を参照してください。イベントの処理と発生です。
例
次の例に応答する方法を示しています。、KeyPressイベント ハンドラーでイベントです。 この例では、 RectangleShape RectangleShape1 という名前のフォームにコントロールです。
Private Sub RectangleShape1_KeyPress(
ByVal sender As Object,
ByVal e As System.Windows.Forms.KeyPressEventArgs
) Handles RectangleShape1.KeyPress
Dim ch As Char
ch = e.KeyChar
MsgBox("You pressed the " & ch & " key.")
End Sub
private void rectangleShape1_KeyPress(object sender,
System.Windows.Forms.KeyPressEventArgs e)
{
char ch;
ch = e.KeyChar;
MessageBox.Show("You pressed the " + ch + " key.");
}
.NET Framework セキュリティ
- 直前の呼び出し元に対する完全な信頼。このメンバーは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。
参照
関連項目
Microsoft.VisualBasic.PowerPacks 名前空間
その他の技術情報
方法 : LineShape コントロールを使用して線を描画する (Visual Studio)
方法 : OvalShape コントロールおよび RectangleShape コントロールを使用して図形を描画する (Visual Studio)