TreeView.AfterSelect 事件
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
發生於選取樹狀節點之後。
public:
event System::Windows::Forms::TreeViewEventHandler ^ AfterSelect;
public event System.Windows.Forms.TreeViewEventHandler AfterSelect;
public event System.Windows.Forms.TreeViewEventHandler? AfterSelect;
member this.AfterSelect : System.Windows.Forms.TreeViewEventHandler
Public Custom Event AfterSelect As TreeViewEventHandler
事件類型
範例
下列程式碼範例示範如何使用 TreeViewAction 列舉。 若要執行此範例,請將下列程式碼貼到包含 TreeView 名為 TreeView1
之控制項的表單中。 這個範例會要求 TreeView1
填入專案,而且 AfterSelect 事件會連接到範例中定義的事件處理常式。
private:
// Handle the After_Select event.
void TreeView1_AfterSelect( System::Object^ /*sender*/, System::Windows::Forms::TreeViewEventArgs^ e )
{
// Vary the response depending on which TreeViewAction
// triggered the event.
switch ( (e->Action) )
{
case TreeViewAction::ByKeyboard:
MessageBox::Show( "You like the keyboard!" );
break;
case TreeViewAction::ByMouse:
MessageBox::Show( "You like the mouse!" );
break;
}
}
// Handle the After_Select event.
private void TreeView1_AfterSelect(System.Object sender,
System.Windows.Forms.TreeViewEventArgs e)
{
// Vary the response depending on which TreeViewAction
// triggered the event.
switch((e.Action))
{
case TreeViewAction.ByKeyboard:
MessageBox.Show("You like the keyboard!");
break;
case TreeViewAction.ByMouse:
MessageBox.Show("You like the mouse!");
break;
}
}
' Handle the After_Select event.
Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.TreeViewEventArgs) _
Handles TreeView1.AfterSelect
' Vary the response depending on which TreeViewAction
' triggered the event.
Select Case (e.Action)
Case TreeViewAction.ByKeyboard
MessageBox.Show("You like the keyboard!")
Case TreeViewAction.ByMouse
MessageBox.Show("You like the mouse!")
End Select
End Sub
備註
取消選取節點時,不會發生此事件。 若要偵測選取範圍是否已清除,您可以測試 TreeNode.IsSelected 屬性。
如需處理事件的詳細資訊,請參閱 處理和引發事件。
適用於
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應