バージョン

IncludeCollapsedDescendantsOnRangeSelection プロパティ (BeforeSelectEventArgs)

これらの縮小されたノードが範囲選択の最初のノードと最後のノードの間にある時に縮小されたノードの子孫が選択されるかどうかを取得または設定します。
シンタックス
'宣言
 
Public Property IncludeCollapsedDescendantsOnRangeSelection As Boolean
public bool IncludeCollapsedDescendantsOnRangeSelection {get; set;}
解説

範囲選択が実行されている場合に限り、IncludeCollapsedDescendantsOnRangeSelection プロパティは適用できます。Control キーを押しながらノードをクリックして選択を拡張することは範囲選択にはなりません。

UltraTree コントロールは IncludeCollapsedDescendantsOnRangeSelection プロパティも公開します。コントロールレベル プロパティの値はこのプロパティの初期値を決定します。このプロパティの値を変更すると、コントロールレベル プロパティによって指定された動作をオーバーライドします。

範囲選択の最後のノードの子孫は選択されません。つまりクリックまたはドラッグされた最後のノードは選択の最後のメンバーを表します。

使用例
Imports System.Collections.Generic
Imports Infragistics.Win
Imports Infragistics.Win.Misc.UltraWinTree

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '  Set the SelectionBehavior property to 'ExtendedAcrossCollections'
        '  to allow nodes from different collections to be selected concurrently.
        Me.ultraTree1.SelectionBehavior = SelectionBehavior.ExtendedAcrossCollections

        '  Add nodes to the tree
        Me.PopulateTree(Me.ultraTree1)

        '  Determine the deepest level 
        Dim deepestLevel As Integer = Me.GetDeepestLevel(Me.ultraTree1)

        '  Only allow selection of leaf nodes
        Me.AllowSelectionOnLevel(Me.ultraTree1, deepestLevel)
    End Sub

    Private Sub PopulateTree(ByVal treeControl As UltraTree)
        Try

            treeControl.BeginUpdate()
            treeControl.Nodes.Clear()

            Dim i As Integer
            For i = 0 To 2

                Dim text As String = String.Format("Root {0}", i)
                Dim rootNode As UltraTreeNode = treeControl.Nodes.Add(Nothing, text)
                Me.PopulateNodes(rootNode.Nodes, 1)
            Next

        Finally
            treeControl.EndUpdate()
        End Try

        treeControl.ExpandAll()

    End Sub

    Private Sub PopulateNodes(ByVal nodesCollection As TreeNodesCollection, ByVal level As Integer)

        If (level > 3) Then Return

        Dim parentNode As UltraTreeNode = nodesCollection.ParentNode

        Dim i As Integer
        For i = 0 To 2

            Dim text As String = String.Format("{0}\Node {1}", parentNode.Text, i)
            Dim node As UltraTreeNode = nodesCollection.Add(Nothing, text)

            If (level < 3) Then
                Me.PopulateNodes(node.Nodes, level + 1)
            End If
        Next

    End Sub


    Private Sub ultraTree1_BeforeSelect(ByVal sender As System.Object, ByVal e As BeforeSelectEventArgs) Handles ultraTree1.BeforeSelect
        '  Iterate the members of the new selection and check
        '  the level of each node to determine which levels are
        '  included in the selection.
        Dim selectedNodes As SelectedNodesCollection = e.NewSelections
        Dim levels As New List(Of Integer)
        Dim i As Integer
        For i = 0 To selectedNodes.Count - 1

            Dim node As UltraTreeNode = selectedNodes(i)

            Dim level As Integer = node.Level
            If levels.Contains(level) = False Then levels.Add(level)
        Next

        '  If there are no root level nodes selected, allow descendants
        '  of collapsed nodes to be selected.
        If (levels.Contains(0) = False) Then
            e.IncludeCollapsedDescendantsOnRangeSelection = True
        End If

    End Sub
using System.Collections.Generic;
using Infragistics.Win;
using Infragistics.Win.Misc.UltraWinTree;

    private void Form1_Load(object sender, EventArgs e)
    {
        //  Set the SelectionBehavior property to 'ExtendedAcrossCollections'
        //  to allow nodes from different collections to be selected concurrently.
        this.ultraTree1.SelectionBehavior = SelectionBehavior.ExtendedAcrossCollections;

        //  Set the IncludeCollapsedDescendantsOnRangeSelection property to false
        //  so that descendants of collapsed nodes are not selected by default.
        this.ultraTree1.IncludeCollapsedDescendantsOnRangeSelection = DefaultableBoolean.False;

        //  Add nodes to the tree
        this.PopulateTree( this.ultraTree1 );
    }

    private void PopulateTree( UltraTree treeControl, bool expandAll )
    {
        try
        {
            treeControl.BeginUpdate();

            treeControl.Nodes.Clear();

            for ( int i = 0; i < 3; i ++ )
            {
                string text = string.Format( "Root {0}", i );
                UltraTreeNode rootNode = treeControl.Nodes.Add( null, text );
                this.PopulateNodes( rootNode.Nodes, 1 );
            }

            if ( expandAll )
                this.ultraTree1.ExpandAll();
        }
        finally
        {
            treeControl.EndUpdate();
        }
    }

    private void PopulateNodes( TreeNodesCollection nodesCollection, int level )
    {
        if ( level > 3 )
            return;

        UltraTreeNode parentNode = nodesCollection.ParentNode;

        for ( int i = 0; i < 3; i ++ )
        {
            string text = string.Format( @"{0}\Node {1}", parentNode.Text, i );
            UltraTreeNode node = nodesCollection.Add( null, text );
            
            if ( level < 3 )
                this.PopulateNodes( node.Nodes, level + 1 );
        }            
    }

    private void ultraTree1_BeforeSelect(object sender, BeforeSelectEventArgs e)
    {
        //  Iterate the members of the new selection and check
        //  the level of each node to determine which levels are
        //  included in the selection.
        SelectedNodesCollection selectedNodes = e.NewSelections;
        List<int> levels = new List<int>();
        for ( int i = 0; i < selectedNodes.Count; i ++ )
        {
            UltraTreeNode node = selectedNodes[i];

            int level = node.Level;
            if ( levels.Contains(level) == false )
                levels.Add(level);
        }

        //  If there are no root level nodes selected, allow descendants
        //  of collapsed nodes to be selected.
        if ( levels.Contains(0) == false )
            e.IncludeCollapsedDescendantsOnRangeSelection = true;
    }
参照