ListView.ItemActivate 事件
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
當物品被啟動時發生。
public:
event EventHandler ^ ItemActivate;
public event EventHandler ItemActivate;
public event EventHandler? ItemActivate;
member this.ItemActivate : EventHandler
Public Custom Event ItemActivate As EventHandler
事件類型
範例
以下程式碼範例展示了此成員的使用方式。 在這個例子中,事件處理者會回報事件 ItemActivate 的發生情況。 此報告能幫助您了解事件發生時間,並協助除錯。 若要報告多個事件或頻繁發生的事件,請考慮將MessageBox.Show訊息替換Console.WriteLine為或附加於多行TextBox。
要執行範例程式碼,請將其貼到包含一個 ListView 名為 ListView1的實例的專案中。 然後確保事件處理程式與事件 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 程序中,你可以參考 SelectedItems OR SelectedIndices 屬性,存取選取的 ListView 項目集合,以判斷哪些項目被啟動。
如需處理事件的詳細資訊,請參閱 處理和引發事件。