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

Centering a node vertically

Thread ID:

Created:

Updated:

Platform:

Replies:

51347 Nov 3,2006 06:48 AM UTC Nov 10,2006 08:45 AM UTC WinForms 6
loading
Tags: Tools
Hardiyanto Johandoko
Asked On November 3, 2006 06:48 AM UTC

Hi there,

I'm currently using Syncfusion version 3.3.0.0. In particular, I have a TreeViewAdv that contains so many nodes that the vertical scrollbar is visible. I'm wondering whether it is possible to bring a node into view as close to the vertical center as possible. To my understanding, there is a BringIntoView method but it will only scroll the tree vertically just enough to bring the node into view. In most cases, the node ends up at the top most or bottom most. Please advise.


Regards,

Hardi

Malarvizhi [Syncfusion]
Replied On November 3, 2006 10:03 AM UTC

Hi Hardi,

We regret for the inconvenience caused.

This is a known issue and we are currently fixing this.Could you please try the following workaround to overcome this issue?



TreeNodeAdv node = new TreeNodeAdv();
//Code to set the VScroll position.
this.treeViewAdv1.VScrollPos = this.treeViewAdv1.VScrollBar.SmallChange + this.treeViewAdv1.VScrollBar.LargeChange ;
// TreeviewAdv to focus the particular node
node = this.treeViewAdv1.Nodes[15];
this.treeViewAdv1.SelectedNode = this.treeViewAdv1.LastVisibleNode;
this.treeViewAdv1.SelectedNode = node;
this.treeViewAdv1.EnsureVisibleSelectedNode = true;
this.treeViewAdv1.Focus();


I have attached the video file, please go through that and let me know if i understood you correctly.

TreeViewAdvDemo.zip

Regards,
Malarvizhi.


Hardiyanto Johandoko
Replied On November 7, 2006 06:09 AM UTC

Hi Malarvizhi,

Please see the attached code. It was taken from one of the Syncfusion's samples. I modified the application such that the tree lists the folders in "c:\Program Files\" and when the button "Center" is clicked, it will bring the 22nd node into view. Please note that When you click button "Center", it still doesn't center the 22nd node and it seems that it behaves just like the BringIntoView method. Please advise, am I missing something here?

Regards,

Hardi

Center.zip

Malarvizhi [Syncfusion]
Replied On November 7, 2006 09:45 AM UTC

Hi Hardi,

Thanks for your sample.

I was able to reproduce the issue. I have attached the modified sample,please go through that and let me know your issue has been resolved or not.

Center.zip


Regards,
Malarvizhi.

Hardiyanto Johandoko
Replied On November 9, 2006 02:31 AM UTC

Hi Malarvizhi,

First, the workaround works perfectly for node 22, but it doesn't work anymore if you put a higher node number like 40.

Second, this approach seems to work only when the tree is flat (all nodes are collapsed). In the application that I'm currently working on, we have a tree which each node can have different depth. Try the following, expand few nodes above node 22 and click on the button. Notice that the node is not centered anymore.

Regards,

Hardi

Malarvizhi [Syncfusion]
Replied On November 9, 2006 11:04 AM UTC

Hi Hardi.

We regret for the inconvenience caused.

To view at node at center position(include Expand/collaspe operation),i used to set TreeviewAdv.VScrollPos by the following values.

//TextBox value is node to be viewed.
this.treeViewAdv1.VScrollPos = (this.treeViewAdv1.ItemHeight * int.Parse(this.textBox1.Text) / (this.treeViewAdv1.VScrollBar.SmallChange+this.treeViewAdv1.VScrollBar.LargeChange));

TreeviewAdv.ItemHeight :Indicated the default height of the nodes.
TextBox1.Text - position of the node to be viewed
TreeviewAdv.VScrollBar.SmallChange-Indicates the value of the scrollbox moved a small distance
TreeviewAdv.VScrollBar.LargeChange-Indicates the value of the scrollbox moved a large distance.

I attached the sample.please go through that and let me know its works for you.
TreeViewCenterNode.zip


Regards,
Malarvizhi.

Hardiyanto Johandoko
Replied On November 10, 2006 08:45 AM UTC

Hi Malarvizhi

I'm really sorry but your solution only works for certain nodes. But your approach made me realize that the problem can be solved by simple math. Thank you for your help.

Attached is your modified code.

Regards,

Hardi





TreeViewCenterNode.zip

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

;