Treeview Shift-Click to select multiple items in sequence

Posted by: dphillips on 30 June 2022, 6:11 am EST

    • Post Options:
    • Link

    Posted 30 June 2022, 6:11 am EST

    Is there a way to allow the user to click on the 1st item in the treeview, and then shift+click on a later item and have it select all items in between?

  • Posted 30 June 2022, 6:32 pm EST

    Hi,

    You need to handle ItemExpanded event to select 1st item on expanding a Parent node as:

    
            private void Item_Expanded(object sender, SourcedEventArgs e)
            {
                var node = e.Source as C1TreeViewItem;
                if(node != null)
                {
                    if(node.HasItems)
                    {
                        node.FirstNode.IsSelected = true;
                    }
                }
            }
    
    

    In order to achieve the requirement to select items using Shift+Click. You need to set SelectionMode=True. On expanding parent node the first item will be selected and then shift+click on a later item will select all items between them.

    Please refer the attached sample for the same : C1TreeViewSample.zip

    Best Regards,

    Nitin

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels