ListView.ItemActivate 事件

定義

發生於啟動項目時。

public:
 event EventHandler ^ ItemActivate;
public event EventHandler ItemActivate;
public event EventHandler? ItemActivate;
member this.ItemActivate : EventHandler 
Public Custom Event ItemActivate As EventHandler 

事件類型

範例

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

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

private void ListView1_ItemActivate(Object sender, EventArgs e) {

   MessageBox.Show("You are in the ListView.ItemActivate event.");
}
Private Sub ListView1_ItemActivate(sender as Object, e as EventArgs) _ 
     Handles ListView1.ItemActivate

   MessageBox.Show("You are in the ListView.ItemActivate event.")

End Sub

備註

ItemActivate當使用者在 控制項中 ListView 啟動一或多個專案時,就會發生此事件。 使用者可以使用單鍵或按兩下來啟動專案,視 屬性的值 Activation 而定,或使用鍵盤。 從 事件的事件處理常式 ItemActivate 內,您可以參考 SelectedItemsSelectedIndices 屬性,以存取 中 ListView 選取的專案集合,以判斷要啟動哪些專案。

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

適用於

另請參閱