共用方式為


ToolStripDropDown.KeyUp 事件

定義

發生於放開按鍵且焦點在控制項時。

public:
 event System::Windows::Forms::KeyEventHandler ^ KeyUp;
[System.ComponentModel.Browsable(false)]
public event System.Windows.Forms.KeyEventHandler KeyUp;
[System.ComponentModel.Browsable(false)]
public event System.Windows.Forms.KeyEventHandler? KeyUp;
[<System.ComponentModel.Browsable(false)>]
member this.KeyUp : System.Windows.Forms.KeyEventHandler 
Public Custom Event KeyUp As KeyEventHandler 

事件類型

屬性

範例

下列程式碼範例示範此成員的使用。 在此範例中,事件處理常式會報告事件發生次數 KeyUp 。 此報告可協助您瞭解事件發生的時間,並可協助您進行偵錯。 若要報告多個事件或經常發生的事件,請考慮將 取代 MessageBox.ShowConsole.WriteLine 為 或將訊息附加至多行 TextBox

若要執行範例程式碼,請將它貼到包含名為 ToolStripDropDown1 之型 ToolStripDropDown 別實例的專案。 然後,確定事件處理常式與事件相關聯 KeyUp

private void ToolStripDropDown1_KeyUp(Object sender, KeyEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "Alt", e.Alt );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Control", e.Control );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Handled", e.Handled );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "KeyCode", e.KeyCode );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "KeyValue", e.KeyValue );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "KeyData", e.KeyData );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Modifiers", e.Modifiers );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Shift", e.Shift );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "SuppressKeyPress", e.SuppressKeyPress );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "KeyUp Event" );
}
Private Sub ToolStripDropDown1_KeyUp(sender as Object, e as KeyEventArgs) _ 
     Handles ToolStripDropDown1.KeyUp

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "Alt", e.Alt)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Control", e.Control)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Handled", e.Handled)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "KeyCode", e.KeyCode)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "KeyValue", e.KeyValue)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "KeyData", e.KeyData)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Modifiers", e.Modifiers)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Shift", e.Shift)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "SuppressKeyPress", e.SuppressKeyPress)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"KeyUp Event")

End Sub

備註

如需處理事件的詳細資訊,請參閱 處理和引發事件

適用於