TreeViewCancelEventArgs.Action 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
獲得 TreeView 那種提升事件的行動。
public:
property System::Windows::Forms::TreeViewAction Action { System::Windows::Forms::TreeViewAction get(); };
public System.Windows.Forms.TreeViewAction Action { get; }
member this.Action : System.Windows.Forms.TreeViewAction
Public ReadOnly Property Action As TreeViewAction
屬性值
這是其中一項 TreeViewAction 價值。
範例
以下程式碼範例展示了此成員的使用方式。 在這個例子中,事件處理者會回報事件 TreeView.BeforeCheck 的發生情況。 此報告能幫助您了解事件發生時間,並協助除錯。 若要報告多個事件或頻繁發生的事件,請考慮將MessageBox.Show訊息替換Console.WriteLine為或附加於多行TextBox。
要執行範例程式碼,請將其貼到包含一個 TreeView 名為 TreeView1的實例的專案中。 然後確保事件處理程式與事件 TreeView.BeforeCheck 相關聯。
private void TreeView1_BeforeCheck(Object sender, TreeViewCancelEventArgs e) {
System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "Node", e.Node );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Action", e.Action );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Cancel", e.Cancel );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "BeforeCheck Event" );
}
Private Sub TreeView1_BeforeCheck(sender as Object, e as TreeViewCancelEventArgs) _
Handles TreeView1.BeforeCheck
Dim messageBoxVB as New System.Text.StringBuilder()
messageBoxVB.AppendFormat("{0} = {1}", "Node", e.Node)
messageBoxVB.AppendLine()
messageBoxVB.AppendFormat("{0} = {1}", "Action", e.Action)
messageBoxVB.AppendLine()
messageBoxVB.AppendFormat("{0} = {1}", "Cancel", e.Cancel)
messageBoxVB.AppendLine()
MessageBox.Show(messageBoxVB.ToString(),"BeforeCheck Event")
End Sub