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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Control location in TreeViewAdv

Thread ID:

Created:

Updated:

Platform:

Replies:

126227 Oct 3,2016 03:41 AM UTC Oct 5,2016 04:05 AM UTC WinForms 5
loading
Tags: TreeViewAdv
Nicolas
Asked On October 3, 2016 03:41 AM UTC

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


Senthil Kumaran Rajan [Syncfusion]
Replied On 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 


Nicolas
Replied On 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

Senthil Kumaran Rajan [Syncfusion]
Replied On 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 

Nicolas
Replied On October 4, 2016 07:24 PM UTC

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

Senthil Kumaran Rajan [Syncfusion]
Replied On 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 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

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

;