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. Image for the cookie policy date
close icon

Control location in TreeViewAdv

Hi, I am trying to change the location of all the controls in a TreeViewAdv, and apparently, it is not taking the value. I tried several other variants with the same result. Thanks in advance! - Nicolas

For i = 0 To TreeViewAdv1.Controls.Count - 1

TreeViewAdv1.Controls(i).Location = New Point(200, 0)

Next


5 Replies

SK Senthil Kumaran Rajan Syncfusion Team October 3, 2016 11:59 AM UTC

Hi Nicolas, 
 
Thanks for contacting Syncfusion Support. 
 
We can customize the location of nodes in TreeViewAdv by using the property named “Indent” and each custom controls location can be customized by using the property named ”CustomControlLocation”. Please make use of the below code example. 
 
Code Example[C#]: 
 
'To set the location of the Nodes. 
Me.treeViewAdv1.Indent += 10 
'To Set the location for the custom control. 
For i As Integer = 0 To Me.treeViewAdv1.Nodes.Count - 1 
Me.treeViewAdv1.Nodes(i).CustomControlLocation = New Point(Me.treeViewAdv1.Nodes(i).CustomControlLocation.X + 10, Me.treeViewAdv1.Nodes(i).CustomControlLocation.Y) 
Next i 
 
 
We have prepared the sample for your reference and it can be downloaded from the below location. 
 
 
Could you check with the above solution and let us know whether it is helpful? If not please share us some additional details about the reported behavior. It will be helpful for us to analyze and provide you a prompt solution at the earliest.   
 
Regards, 
Senthil 



NI Nicolas October 3, 2016 02:31 PM UTC

Hi, I tried this, and the setting of location is working using the "CustomControlLocation", but not quite as intended. Apparently, this location is a location which is dependent of the given name of the node. So, even if we use the same X and Y location for all nodes, the controls will still be misaligned. I would like these controls to be perfectly aligned with each other, thanks in advance - Nicolas


SK Senthil Kumaran Rajan Syncfusion Team October 4, 2016 11:54 AM UTC

Hi Nicolas,  
  
Thank you for your update.  
  
We assume that your requirement is to align all the custom control in the same X and Y location. If so the reported requirement can be achieved by finding the largest node from the TreeViewAdv and assigning the proper control location. Please make use of the below code example.  
  
Code Example[VB]:  
  
Private Sub buttonAdv2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles buttonAdv2.Click  
            'To Set the location for the custom control.  
            Dim node As TreeNodeAdv = Nothing  
            Dim longest As String = Me.treeViewAdv1.Nodes(0).Nodes(0).Text  
            'To find the largest test from the collection of child node.   
            For Each tree As TreeNodeAdv In Me.treeViewAdv1.Nodes(0).Nodes  
                If tree.Text.Length > longest.Length Then  
                    node = tree  
                    longest = node.Text  
                End If  
            Next  
            'To set the customcontrol location.  
            For Each custombound As TreeNodeAdv In Me.treeViewAdv1.Nodes(0).Nodes  
                custombound.CustomControlLocation = New Point((node.TextBounds.X + node.TextBounds.Width - custombound.TextBounds.Width), custombound.CustomControlLocation.Y)  
            Next  
  
        End Sub  
  
  
We have prepared the sample for your reference and this can be downloaded from the below location.   
  
  
You can also refer the below screenshot for further reference.  
  
Screenshot:  
  
   
  
Could you check with the above solution and let us know whether it is helpful? If not please share us some additional details about the reported behavior. It will be helpful for us to analyze and provide you a appropriate solution at the earliest.    
  
Regards,  
Senthil 


NI Nicolas October 4, 2016 07:24 PM UTC

Yes, this is exactly what I needed! Thank you again for your support! - Nicolas


SK Senthil Kumaran Rajan Syncfusion Team October 5, 2016 04:05 AM UTC

Hi Nicolas, 
 
Thank you for your update. 
 
We are glad to know that, your requirement has been achieved. Please let us know if you need any further assistance, we will be happy to assist you. 
 
Regards, 
Senthil 


Loader.
Live Chat Icon For mobile
Up arrow icon