)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to improve WinForms TreeViewAdv's performance when selecting more than a thousand nodes?

Platform: WinForms |
Control: TreeViewAdv |
Published Date: January 2, 2015 |
Last Revised Date: February 5, 2020

Performance of TreeViewAdv

The performance of TreeViewAdv when selecting more than thousand nodes can be improved by handling the following TreeViewAdv events:

1. MouseUp event

2. KeyUp event

3. KeyDown event

C#

void treeViewAdv1_MouseUp(object sender, MouseEventArgs e)
{
    if(Control.ModifierKeys == Keys.Shift)
    {
       TreeNodeAdv node = this.treeViewAdv1.PointToNode(e.Location);
       int index = this.treeViewAdv1.NodeToRowIndex(node);
       int endindex = this.treeViewAdv1.NodeToRowIndex(this.treeViewAdv1.SelectedNode);
       int incre=index>endindex?-1:1;                
       this.treeViewAdv1.SelectedNodes.Clear();                            
       for (int i = index; ; i += incre)
       {
           this.treeViewAdv1.SelectedNodes.Add(this.treeViewAdv1.RowIndexToNode(i));
           if(endindex == i)
           {
              break;
           }
       }                
    }
}

VB

Private Sub treeViewAdv1_MouseUp(sender As Object, e As MouseEventArgs)
   If Control.ModifierKeys = Keys.Shift Then
      Dim node As TreeNodeAdv = Me.treeViewAdv1.PointToNode(e.Location)
      Dim index As Integer = Me.treeViewAdv1.NodeToRowIndex(node)
      Dim endindex As Integer = Me.treeViewAdv1.NodeToRowIndex(Me.treeViewAdv1.SelectedNode)
      Dim incre As Integer = If(index > endindex, -1, 1)
      Me.treeViewAdv1.SelectedNodes.Clear()
      Dim i As Integer = index
      While True
           Me.treeViewAdv1.SelectedNodes.Add(Me.treeViewAdv1.RowIndexToNode(i))
           If endindex = i Then
              Exit While
           End If
           i += incre
      End While
   End If
End Sub

Sample: http://www.syncfusion.com/downloads/support/directtrac/general/TreeViewAdvSample946095543.zip

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon