TreeViewAction 列舉
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
指定引發 TreeViewEventArgs 事件的動作。
public enum class TreeViewAction
public enum TreeViewAction
type TreeViewAction =
Public Enum TreeViewAction
- 繼承
欄位
| 名稱 | 值 | Description |
|---|---|---|
| Unknown | 0 | 導致此事件的具體原因不明。 |
| ByKeyboard | 1 | 事件是由一次按鍵引發的。 |
| ByMouse | 2 | 這起事件是由老鼠操作引起的。 |
| Collapse | 3 | 此事件是因為 TreeNode 坍塌所致。 |
| Expand | 4 | 此事件是因為擴張 TreeNode 所致。 |
範例
以下程式碼範例示範如何使用 TreeView.AfterSelect 事件與 TreeViewAction 列舉。 要執行範例,將以下程式碼貼上一個包含名為 TreeView1 的 TreeView 控制項的表單。 此範例假設 TreeView1 已填充項目,且 TreeView.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
備註
此枚舉方式被成員使用,例如 TreeViewEventArgs 建構者。