Shape.KeyDown 事件
發生於按下按鍵且焦點在圖形時。
命名空間: Microsoft.VisualBasic.PowerPacks
組件: Microsoft.VisualBasic.PowerPacks.Vs (在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)
語法
'宣告
<BrowsableAttribute(True)> _
Public Event KeyDown As KeyEventHandler
[BrowsableAttribute(true)]
public event KeyEventHandler KeyDown
[BrowsableAttribute(true)]
public:
event KeyEventHandler^ KeyDown {
void add (KeyEventHandler^ value);
void remove (KeyEventHandler^ value);
}
[<BrowsableAttribute(true)>]
member KeyDown : IEvent<KeyEventHandler,
KeyEventArgs>
JScript 不支援事件。
備註
主要事件發生順序如下:
KeyDown
若要處理鍵盤事件只能在表單層級並不會啟用接收鍵盤事件的圖形,設定Handled屬性在表單的KeyPress事件處理方法來true。
如需如何處理事件的詳細資訊,請參閱處理和引發事件。
範例
下列範例顯示如何回應KeyDown圖形之間的索引標籤的事件處理常式中的事件。 此範例中您需要RectangleShape名為 RectangleShape1,控制項OvalShape名為 OvalShape1,控制項和LineShape名 LineShape1 為表單上的控制項。
Private Sub Shapes_KeyDown(
ByVal sender As Object,
ByVal e As System.Windows.Forms.KeyEventArgs
) Handles RectangleShape1.KeyDown, OvalShape1.KeyDown,
LineShape1.KeyDown
' Check to see whether the TAB key was pressed.
If e.KeyCode = Keys.Tab Then
' Call the Tab procedure
Tab(sender)
End If
End Sub
Private Sub Tab(ByVal sender As Shape)
' Select the next shape.
sender.Parent.SelectNextShape(sender, True, True)
End Sub
private void Shapes_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
// Check to see whether the TAB key was pressed.
if (e.KeyCode == Keys.Tab)
// Call the Tab procedure
{
Tab((Shape) sender);
}
}
private void Tab(Shape sender)
{
// Select the next shape.
sender.Parent.SelectNextShape(sender, true, true);
}
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。
請參閱
參考
Microsoft.VisualBasic.PowerPacks 命名空間
其他資源
如何:使用 LineShape 控制項繪製線條 (Visual Studio)