TabControlArray.KeyPress 事件


發生於按下按鍵且焦點在控制項時。Occurs when a key is pressed and the control has focus.

 event System::Windows::Forms::KeyPressEventHandler ^ KeyPress;
public event System.Windows.Forms.KeyPressEventHandler KeyPress;
member this.KeyPress : System.Windows.Forms.KeyPressEventHandler 
Public Custom Event KeyPress As KeyPressEventHandler 
Public Event KeyPress As KeyPressEventHandler 


主要事件會依照下列順序發生:Key events occur in the following order:




非字元索引鍵不會引發 KeyPress 事件;不過,非字元索引鍵會引發 KeyDownKeyUp 事件。The KeyPress event is not raised by noncharacter keys; however, the noncharacter keys do raise the KeyDown and KeyUp events.

使用 [KeyChar] 屬性可在執行時間進行按鍵取樣,以及取用或修改常用按鍵的子集。Use the KeyChar property to sample keystrokes at run time and to consume or modify a subset of common keystrokes.

若只要在表單層級處理鍵盤事件,而不讓控制項接收鍵盤事件,請將表單的 KeyPress 事件處理方法中的 Handled 屬性設定為 trueTo handle keyboard events only at the form level and not enable controls to receive keyboard events, set the Handled property in the form's KeyPress event-handling method to true.

如需如何處理事件的詳細資訊,請參閱處理和引發事件For more information about how to handle events, see Handling and Raising Events.


Microsoft.VisualBasic.Compatibility.VB6 命名空間中的函式和物件都是供這些工具使用,以便從 Visual Basic 6.0 升級至 Visual Basic。Functions and objects in the Microsoft.VisualBasic.Compatibility.VB6 namespace are provided for use by the tools for upgrading from Visual Basic 6.0 to Visual Basic. 在大多數情況下,這些函式和物件會複製在 .NET Framework.NET Framework 的其他命名空間中可以找到的功能。In most cases, these functions and objects duplicate functionality that you can find in other namespaces in the .NET Framework.NET Framework. 只有當 Visual Basic 6.0 程式碼模型與 .NET Framework.NET Framework 實作有顯著差異時,才需要這些項目。They are necessary only when the Visual Basic 6.0 code model differs significantly from the .NET Framework.NET Framework implementation.