TreeViewCancelEventArgs.Action プロパティ

定義

イベントを発生させた 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値の 1 つ。

次のコード例は、このメンバーの使用方法を示しています。 この例では、イベント ハンドラーは、 TreeView.BeforeCheck イベントの発生を報告します。 このレポートは、イベントがいつ発生するかを学習するのに役立ち、デバッグに役立ちます。 複数のイベントや頻繁に発生するイベントについて報告するには、 MessageBox.ShowConsole.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

適用対象

こちらもご覧ください