I have a treeview whose initial size is 500 x 450 (width x height).
I would like the tree view rectangle to autosize as nodes are expanded/contracted.
Even though I set autosize = true, and give it a minsize > (0,0) and maxsize > minSize, the autosizing does not happen.
Is there any trick to autosizing a treeview?
I am using Q1 2008 SP1.
Thanks
Sunil
I would like the tree view rectangle to autosize as nodes are expanded/contracted.
Even though I set autosize = true, and give it a minsize > (0,0) and maxsize > minSize, the autosizing does not happen.
Is there any trick to autosizing a treeview?
I am using Q1 2008 SP1.
Thanks
Sunil
37 Answers, 1 is accepted
0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 12 Dec 2010, 03:18 PM
Hi Sunil,
from what I understand you want to prevent the VScrollbar from appearing on the client area of the RadtreeView by automatically expanding and collapsing the area depending on the state of the nodes.
Please try adding the following code:
I have added a link to a small screencast movie clip to show this working in the way I think you want.
Hope this helps
Richard
from what I understand you want to prevent the VScrollbar from appearing on the client area of the RadtreeView by automatically expanding and collapsing the area depending on the state of the nodes.
Please try adding the following code:
Private Sub RadTreeView1_NodeExpandedChanged(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.RadTreeViewEventArgs) Handles RadTreeView1.NodeExpandedChanged If e.Node.Expanded Then If Me.RadTreeView1.VScrollBar.Visible Then While Me.RadTreeView1.VScrollBar.Visible Me.RadTreeView1.Height = Me.RadTreeView1.Height + 1 End While End If Else If Me.RadTreeView1.VScrollBar.Visible = False Then While Me.RadTreeView1.VScrollBar.Visible = False Me.RadTreeView1.Height = Me.RadTreeView1.Height - 1 End While Me.RadTreeView1.Height = Me.RadTreeView1.Height + 1 End If End IfEnd SubI have added a link to a small screencast movie clip to show this working in the way I think you want.
Hope this helps
Richard
0
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
answered on 12 Dec 2010, 03:41 PM
Hi Richard,
I appreciate your reply and help.
I was looking for vertical as well as horizontal scroll bars from not appearing.
It seems I would implement something similar for horizontal scroll not appearing.
Also, when the grid view first renders, I guess I would have to run a similar logic just after binding the tree view?
Thanks
Sunil
I appreciate your reply and help.
I was looking for vertical as well as horizontal scroll bars from not appearing.
It seems I would implement something similar for horizontal scroll not appearing.
Also, when the grid view first renders, I guess I would have to run a similar logic just after binding the tree view?
Thanks
Sunil
0
Richard Slade
Top achievements
Rank 2
answered on 12 Dec 2010, 05:13 PM
Hi Sunil,
Please try this..
In this example, I already have some nodes set up. As long as you call
After you have bound your nodes, and as per the exmaple shown below, this should work.
Hope that helps
Richard
Please try this..
In this example, I already have some nodes set up. As long as you call
ResizeClientArea()After you have bound your nodes, and as per the exmaple shown below, this should work.
Hope that helps
Richard
0
Richard Slade
Top achievements
Rank 2
answered on 12 Dec 2010, 05:13 PM
Apologies, now with the code!
Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ' Load in some nodes ResizeClientArea() End Sub Private Sub RadTreeView1_NodeExpandedChanged(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.RadTreeViewEventArgs) Handles RadTreeView1.NodeExpandedChanged ResizeClientArea() End Sub Private Sub ResizeClientArea() If Me.RadTreeView1.HScrollBar.Visible Then While Me.RadTreeView1.HScrollBar.Visible Me.RadTreeView1.Width = Me.RadTreeView1.Width + 1 End While Else While Me.RadTreeView1.HScrollBar.Visible = False Me.RadTreeView1.Width = Me.RadTreeView1.Width - 1 End While Me.RadTreeView1.Width = Me.RadTreeView1.Width + 1 End If If Me.RadTreeView1.VScrollBar.Visible Then While Me.RadTreeView1.VScrollBar.Visible Me.RadTreeView1.Height = Me.RadTreeView1.Height + 1 End While Else While Me.RadTreeView1.VScrollBar.Visible = False Me.RadTreeView1.Height = Me.RadTreeView1.Height - 1 End While Me.RadTreeView1.Height = Me.RadTreeView1.Height + 1 End If Me.RadTreeView1.VScrollBar.Visible = False Me.RadTreeView1.HScrollBar.Visible = False End Sub End Class0
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
answered on 12 Dec 2010, 05:33 PM
Hi Richard,
I tried your approach, first with a step of 1 and then a step of 5.
I found that sometimes it is very fast, and sometimes too slow in rendering the tree.
My soituation is as follows : there is a dropdown of items from which I select an item and click on 'Get BOM' button, which gets the tree hierarchy of the selected item's BOM.
If the last BOM and current BOM height are close to each other then it renders very fast with your solution, but if the difference is large then it renders very slowly.
The performance is the only bottleneck I am seeing. Can you suggest another modified solution?
Thanks
Sunil
I tried your approach, first with a step of 1 and then a step of 5.
I found that sometimes it is very fast, and sometimes too slow in rendering the tree.
My soituation is as follows : there is a dropdown of items from which I select an item and click on 'Get BOM' button, which gets the tree hierarchy of the selected item's BOM.
If the last BOM and current BOM height are close to each other then it renders very fast with your solution, but if the difference is large then it renders very slowly.
The performance is the only bottleneck I am seeing. Can you suggest another modified solution?
Thanks
Sunil
0
Richard Slade
Top achievements
Rank 2
answered on 12 Dec 2010, 05:41 PM
Hi Sunil,
Are you able to post an exmaple so I can try this out for you please? If you can, i'll do my best to improve it for you.
Best regards,
Richard
Are you able to post an exmaple so I can try this out for you please? If you can, i'll do my best to improve it for you.
Best regards,
Richard
0
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
answered on 12 Dec 2010, 06:29 PM
Hi Richard,
The screen I am using your solution on is part of a big application and so its difficult to post an exact example for this.
But you can easily create a sample with a combobox and a treeview. In combobox, have 3 items called Item1, Item2 and Item3.
When Item1 is selected, clear all tree nodes and then create treeview nodes dynamically upto 3 levels. When Item2 is selected create nodes dynamically upto 9 levels and when Item 3 is selected create nodes upto 2 levels. For dynamic creation of nodes, I found the folowing code in Q1 2008 SP1 samples.
You can then go from one item to another, and see the performance when the height difference or width difference is a lot.
Thanks
Sunil
The screen I am using your solution on is part of a big application and so its difficult to post an exact example for this.
But you can easily create a sample with a combobox and a treeview. In combobox, have 3 items called Item1, Item2 and Item3.
When Item1 is selected, clear all tree nodes and then create treeview nodes dynamically upto 3 levels. When Item2 is selected create nodes dynamically upto 9 levels and when Item 3 is selected create nodes upto 2 levels. For dynamic creation of nodes, I found the folowing code in Q1 2008 SP1 samples.
You can then go from one item to another, and see the performance when the height difference or width difference is a lot.
Thanks
Sunil
int index = 0; for (int i = 0; i < 10; i++) { index++; RadTreeNode node = new RadTreeNode("Node" + index); this.radTreeView1.Nodes.Add(node); for (int j = 0; j < 5; j++) { index++; RadTreeNode child = new RadTreeNode("Node" + index); node.Nodes.Add(child); for (int p = 0; p < 2; p++) { index++; RadTreeNode childChild = new RadTreeNode("Node" + index); child.Nodes.Add(childChild); } }}0
Richard Slade
Top achievements
Rank 2
answered on 12 Dec 2010, 07:24 PM
Hi Sunil,
I've tried it by using the code below. It's not lightening fast, but on my PC, I wouldn't say there is a huge delay. I opened up all nodes on the 9 levels one and then shut the top level nodes. I've uploaded the screencast video of the speed at this URL so you could see what I was doing.
I haven't been able to speed it up any more than that at the moment, but I'll continue to have a think about how it may be done. Perhaps there is a simpler way that i've just missed.
regards,
Richard
I've tried it by using the code below. It's not lightening fast, but on my PC, I wouldn't say there is a huge delay. I opened up all nodes on the 9 levels one and then shut the top level nodes. I've uploaded the screencast video of the speed at this URL so you could see what I was doing.
I haven't been able to speed it up any more than that at the moment, but I'll continue to have a think about how it may be done. Perhaps there is a simpler way that i've just missed.
Imports Telerik.WinControls.UI Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ' Load in some nodes ResizeClientArea() End Sub Private Sub RadTreeView1_NodeExpandedChanged(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.RadTreeViewEventArgs) Handles RadTreeView1.NodeExpandedChanged ResizeClientArea() End Sub Private Sub ResizeClientArea() If Me.RadTreeView1.HScrollBar.Visible Then While Me.RadTreeView1.HScrollBar.Visible Me.RadTreeView1.Width = Me.RadTreeView1.Width + 5 End While Else While Me.RadTreeView1.HScrollBar.Visible = False Me.RadTreeView1.Width = Me.RadTreeView1.Width - 5 End While Me.RadTreeView1.Width = Me.RadTreeView1.Width + 5 End If If Me.RadTreeView1.VScrollBar.Visible Then While Me.RadTreeView1.VScrollBar.Visible Me.RadTreeView1.Height = Me.RadTreeView1.Height + 5 End While Else While Me.RadTreeView1.VScrollBar.Visible = False Me.RadTreeView1.Height = Me.RadTreeView1.Height - 5 End While Me.RadTreeView1.Height = Me.RadTreeView1.Height + 5 End If Me.RadTreeView1.VScrollBar.Visible = False Me.RadTreeView1.HScrollBar.Visible = False End Sub Private Sub RadDropDownList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.Data.PositionChangedEventArgs) Handles RadDropDownList1.SelectedIndexChanged Select Case Me.RadDropDownList1.SelectedIndex Case 0 Me.RadTreeView1.Nodes.Clear() For i As Integer = 0 To 4 Me.RadTreeView1.Nodes.Add(i.ToString()) Next For Each node As RadTreeNode In Me.RadTreeView1.Nodes node.Nodes.Add("Some Node") For Each node1 As RadTreeNode In node.Nodes node1.Nodes.Add("Some Node") For Each node2 As RadTreeNode In node.Nodes node2.Nodes.Add("Some Node") Next Next Next ResizeClientArea() Case 1 Me.RadTreeView1.Nodes.Clear() For i As Integer = 0 To 4 Me.RadTreeView1.Nodes.Add(i.ToString()) Next For Each node As RadTreeNode In Me.RadTreeView1.Nodes node.Nodes.Add("Some Node") For Each node1 As RadTreeNode In node.Nodes node1.Nodes.Add("Some Node") For Each node2 As RadTreeNode In node1.Nodes node2.Nodes.Add("Some Node") For Each node3 As RadTreeNode In node2.Nodes node3.Nodes.Add("Some Node") For Each node4 As RadTreeNode In node3.Nodes node4.Nodes.Add("Some Node") For Each node5 As RadTreeNode In node4.Nodes node5.Nodes.Add("Some Node") For Each node6 As RadTreeNode In node5.Nodes node6.Nodes.Add("Some Node") For Each node7 As RadTreeNode In node6.Nodes node7.Nodes.Add("Some Node") For Each node8 As RadTreeNode In node7.Nodes node8.Nodes.Add("Some Node") For Each node9 As RadTreeNode In node8.Nodes node9.Nodes.Add("Some Node") Next Next Next Next Next Next Next Next Next Next ResizeClientArea() Case 2 Me.RadTreeView1.Nodes.Clear() For i As Integer = 0 To 4 Me.RadTreeView1.Nodes.Add(i.ToString()) Next For Each node As RadTreeNode In Me.RadTreeView1.Nodes node.Nodes.Add("Some Node") For Each node1 As RadTreeNode In node.Nodes node1.Nodes.Add("Some Node") For Each node2 As RadTreeNode In node1.Nodes node2.Nodes.Add("Some Node") For Each node3 As RadTreeNode In node2.Nodes node3.Nodes.Add("Some Node") Next Next Next Next ResizeClientArea() End Select End SubEnd Classregards,
Richard
0
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
answered on 12 Dec 2010, 07:33 PM
Hi Richard,
I really appreciate your prompt help.
Before I posted this thread, I tried the following solution without success, where I was always off by a few pixels like 50 or 100. The maxright calculation was not always accurate. In some cases I got 300 to 400 pixels of empty space after the rightmost node, but most times the max right was about 100 pixels less than the actual max right.
On the other hand, the max bottom was always like 50 or so less than actual max bottom.
I am using Q1 2008 SP1 version.
Thanks
Sunil
I really appreciate your prompt help.
Before I posted this thread, I tried the following solution without success, where I was always off by a few pixels like 50 or 100. The maxright calculation was not always accurate. In some cases I got 300 to 400 pixels of empty space after the rightmost node, but most times the max right was about 100 pixels less than the actual max right.
On the other hand, the max bottom was always like 50 or so less than actual max bottom.
I am using Q1 2008 SP1 version.
Thanks
Sunil
bomRadTreeView.Height = bomRadTreeView.Padding.Bottom+ GetMaxBottom(bomRadTreeView.Nodes[0]) ;bomRadTreeView.Width = bomRadTreeView.Padding.Right +GetMaxRight(bomRadTreeView.Nodes[0]) ;private int GetMaxBottom(RadTreeNode node) { int maxBottom = 0; maxBottom = node.LabelBounds.Bottom ; if (!node.Expanded) { return maxBottom; } foreach (RadTreeNode n in node.Nodes) { maxBottom = Math.Max(maxBottom, GetMaxBottom(n)); } return maxBottom; } private int GetMaxRight(RadTreeNode node) { int maxRight = 0; maxRight = node.LabelBounds.Right; if (!node.Expanded) { return maxRight; } foreach (RadTreeNode n in node.Nodes) { maxRight = Math.Max(maxRight, GetMaxBottom(n)); } return maxRight; }0
Richard Slade
Top achievements
Rank 2
answered on 12 Dec 2010, 07:57 PM
Hi Sunil,
i've tried this out in C# in a new project and i cannot get it to work. I've placed the
on the radTreeView1_NodeExpandedChanged event and after making the selection from the RadDropDownList. there are some differences though in the newer version (I am using Q2 2010). For exmaple, LabelBounds is no longer a property of Node. It is simply Node.Bounds. Perhaps this is making a difference. However, I'm wondering how this worked as
will always get the bounds of the first node in the tree.
Where were you placing this code. If you can let me know I can try and replicate what you have done.
Thanks
Richard
i've tried this out in C# in a new project and i cannot get it to work. I've placed the
this.radTreeView1.Height = this.radTreeView1.Padding.Bottom + GetMaxBottom(this.radTreeView1.Nodes[0]); this.radTreeView1.Width = this.radTreeView1.Padding.Right + GetMaxRight(this.radTreeView1.Nodes[0]);on the radTreeView1_NodeExpandedChanged event and after making the selection from the RadDropDownList. there are some differences though in the newer version (I am using Q2 2010). For exmaple, LabelBounds is no longer a property of Node. It is simply Node.Bounds. Perhaps this is making a difference. However, I'm wondering how this worked as
GetMaxRight(this.radTreeView1.Nodes[0]); Where were you placing this code. If you can let me know I can try and replicate what you have done.
Thanks
Richard
0
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
answered on 12 Dec 2010, 08:06 PM
Hi Richard,
The MaxRight calls MaxRight in a recursive manner starting with the rootnode that you pass to it. Also, if a node is not expanded, then it does not do recursion, since we are not displaying the nodes under a collapsed node.
Actually, I just discovered a mistake in my last posted MaxRight where I was calling MaxBottom recursively inside MaxRight. Please change it in your sample project.
The basic idea is 'recursion' starting from the rootnode that is passed to the method. I am only off by 50 to 100 pixels always. So if I know where I am off by 50 or 100 pixels, I will have the answer. Also, the recursion is quick using MaxRight and MaxBottom functions.
The correct MAxRigth code is as below.
Thanks
Sunil
The MaxRight calls MaxRight in a recursive manner starting with the rootnode that you pass to it. Also, if a node is not expanded, then it does not do recursion, since we are not displaying the nodes under a collapsed node.
Actually, I just discovered a mistake in my last posted MaxRight where I was calling MaxBottom recursively inside MaxRight. Please change it in your sample project.
The basic idea is 'recursion' starting from the rootnode that is passed to the method. I am only off by 50 to 100 pixels always. So if I know where I am off by 50 or 100 pixels, I will have the answer. Also, the recursion is quick using MaxRight and MaxBottom functions.
The correct MAxRigth code is as below.
Thanks
Sunil
private int GetMaxRight(RadTreeNode node) { int maxRight = 0; maxRight = node.LabelBounds.Right; if (!node.Expanded) { return maxRight; } foreach (RadTreeNode n in node.Nodes) { maxRight = Math.Max(maxRight, GetMaxRight(n)); } return maxRight; }0
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
answered on 12 Dec 2010, 08:07 PM
Hi Richard,
Sorry I forgot to answer the second part of your question.
I am placing this code in bomRadTreeView_AfterExpand and bomRadTreeView_AfterCollpase events.
Thanks
Sunil
Sorry I forgot to answer the second part of your question.
I am placing this code in bomRadTreeView_AfterExpand and bomRadTreeView_AfterCollpase events.
Thanks
Sunil
0
Richard Slade
Top achievements
Rank 2
answered on 12 Dec 2010, 08:45 PM
Hi Sunil,
At the moment I cannot get your code to work with anything but the first node. And even with this one I am having to add on 50 to the height and width. I'll continue to look into it for you as soon as I can. A few more differences though: There are no AfterExpand and AfterCollapse events any longer. These are now radTreeView1_NodeExpandedChanged. The closest I can get at the moment is the solution I provided. If I can get yours to work in a way that is satisfactory, I'll let you know.
thanks
Richard
At the moment I cannot get your code to work with anything but the first node. And even with this one I am having to add on 50 to the height and width. I'll continue to look into it for you as soon as I can. A few more differences though: There are no AfterExpand and AfterCollapse events any longer. These are now radTreeView1_NodeExpandedChanged. The closest I can get at the moment is the solution I provided. If I can get yours to work in a way that is satisfactory, I'll let you know.
thanks
Richard
0
Richard Slade
Top achievements
Rank 2
answered on 12 Dec 2010, 08:48 PM
Hi again,
By the way, I may be getting tored but I don't think this should be there
otherwise it will not do the recursion through the nodes to find the further most at the bottom if the top node is not expanded
Richard
By the way, I may be getting tored but I don't think this should be there
if (!node.Expanded) { return maxBottom; }Richard
0
Richard Slade
Top achievements
Rank 2
answered on 12 Dec 2010, 09:01 PM
Hi Again,
Apologies this is in VB, I'll translate it if you need me to. It's just my old example with an addition. It's about as quick as I can get it at the moment. I'll have a think overnight but we will be struggling against the difference in our versions of RadControls also.
I hope this has helped.
All the best
Richard
Apologies this is in VB, I'll translate it if you need me to. It's just my old example with an addition. It's about as quick as I can get it at the moment. I'll have a think overnight but we will be struggling against the difference in our versions of RadControls also.
I hope this has helped.
Imports Telerik.WinControls.UI Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ' Load in some nodes ResizeClientArea() End Sub Private Sub RadTreeView1_NodeExpandedChanged(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.RadTreeViewEventArgs) Handles RadTreeView1.NodeExpandedChanged ResizeClientArea() End Sub Private Sub ResizeClientArea() NativeMethods.LockWindowUpdate(Me.Handle.ToInt32) If Me.RadTreeView1.HScrollBar.Visible Then While Me.RadTreeView1.HScrollBar.Visible Me.RadTreeView1.Width = Me.RadTreeView1.Width + 10 End While Else While Me.RadTreeView1.HScrollBar.Visible = False Me.RadTreeView1.Width = Me.RadTreeView1.Width - 10 End While Me.RadTreeView1.Width = Me.RadTreeView1.Width + 10 End If If Me.RadTreeView1.VScrollBar.Visible Then While Me.RadTreeView1.VScrollBar.Visible Me.RadTreeView1.Height = Me.RadTreeView1.Height + 10 End While Else While Me.RadTreeView1.VScrollBar.Visible = False Me.RadTreeView1.Height = Me.RadTreeView1.Height - 10 End While Me.RadTreeView1.Height = Me.RadTreeView1.Height + 10 End If Me.RadTreeView1.VScrollBar.Visible = False Me.RadTreeView1.HScrollBar.Visible = False NativeMethods.LockWindowUpdate(0) End Sub Private Sub RadDropDownList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As Telerik.WinControls.UI.Data.PositionChangedEventArgs) Handles RadDropDownList1.SelectedIndexChanged Select Case Me.RadDropDownList1.SelectedIndex Case 0 Me.RadTreeView1.Nodes.Clear() For i As Integer = 0 To 4 Me.RadTreeView1.Nodes.Add(i.ToString()) Next For Each node As RadTreeNode In Me.RadTreeView1.Nodes node.Nodes.Add("Some Node") For Each node1 As RadTreeNode In node.Nodes node1.Nodes.Add("Some Node") For Each node2 As RadTreeNode In node.Nodes node2.Nodes.Add("Some Node") Next Next Next ResizeClientArea() Case 1 Me.RadTreeView1.Nodes.Clear() For i As Integer = 0 To 4 Me.RadTreeView1.Nodes.Add(i.ToString()) Next For Each node As RadTreeNode In Me.RadTreeView1.Nodes node.Nodes.Add("Some Node") For Each node1 As RadTreeNode In node.Nodes node1.Nodes.Add("Some Node") For Each node2 As RadTreeNode In node1.Nodes node2.Nodes.Add("Some Node") For Each node3 As RadTreeNode In node2.Nodes node3.Nodes.Add("Some Node") For Each node4 As RadTreeNode In node3.Nodes node4.Nodes.Add("Some Node") For Each node5 As RadTreeNode In node4.Nodes node5.Nodes.Add("Some Node") For Each node6 As RadTreeNode In node5.Nodes node6.Nodes.Add("Some Node") For Each node7 As RadTreeNode In node6.Nodes node7.Nodes.Add("Some Node") For Each node8 As RadTreeNode In node7.Nodes node8.Nodes.Add("Some Node") For Each node9 As RadTreeNode In node8.Nodes node9.Nodes.Add("Some Node") Next Next Next Next Next Next Next Next Next Next ResizeClientArea() Case 2 Me.RadTreeView1.Nodes.Clear() For i As Integer = 0 To 4 Me.RadTreeView1.Nodes.Add(i.ToString()) Next For Each node As RadTreeNode In Me.RadTreeView1.Nodes node.Nodes.Add("Some Node") For Each node1 As RadTreeNode In node.Nodes node1.Nodes.Add("Some Node") For Each node2 As RadTreeNode In node1.Nodes node2.Nodes.Add("Some Node") For Each node3 As RadTreeNode In node2.Nodes node3.Nodes.Add("Some Node") Next Next Next Next ResizeClientArea() End Select End SubEnd Class Friend NotInheritable Class NativeMethods Private Sub New() End Sub Friend Declare Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal hWnd As IntPtr, _ ByVal wMsg As Integer, _ ByVal wParam As Integer, _ ByVal lParam As Integer) As Integer Friend Declare Function LockWindowUpdate Lib "User32" (ByVal hWnd As Integer) As Integer End ClassAll the best
Richard
0
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
answered on 12 Dec 2010, 09:06 PM
Hi Richard,
If a node is not expanded, then we do not want to get the right values of its children nodes, since the children nodes are not visible. If the node is not expanded, then we simply return the right of the node that is not expanded. The 'if' you have mentioned in your last post, does this logic.
We only need right values of VISIBLE nodes. There are always hidden nodes within a collapsed node but we don't need to look at them to get visible width or visible height. Or may be I am missing something?
Thanks
Sunil
If a node is not expanded, then we do not want to get the right values of its children nodes, since the children nodes are not visible. If the node is not expanded, then we simply return the right of the node that is not expanded. The 'if' you have mentioned in your last post, does this logic.
We only need right values of VISIBLE nodes. There are always hidden nodes within a collapsed node but we don't need to look at them to get visible width or visible height. Or may be I am missing something?
Thanks
Sunil
0
Richard Slade
Top achievements
Rank 2
answered on 12 Dec 2010, 09:15 PM
Hi Sunil,
As I said, it's possible I'm getting tired now but it seems as though you are retuning the max immediatly if the node is not expanded. What about all the nodes below which are visible and expanded. E.g.
Node 1 (collapsed - but has nodes under it) - so returning max
Node 2 (expanded - has expanded nodes below. these are being ignored?) - max already returned.
Is this right?
richard
As I said, it's possible I'm getting tired now but it seems as though you are retuning the max immediatly if the node is not expanded. What about all the nodes below which are visible and expanded. E.g.
Node 1 (collapsed - but has nodes under it) - so returning max
Node 2 (expanded - has expanded nodes below. these are being ignored?) - max already returned.
Is this right?
richard
0
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
answered on 12 Dec 2010, 09:31 PM
Hi Richard,
I am really sorry. But I appreciate all your efforts greatly.
I will create a project using latest version and post it here.
I am dynamically changing the height/width of tree as I expand and collapse a node.
So if I collapse a node, its children are no more visible. So why would I need to know how much height and width, these invisible nodes are occupying? If a node is collapsed, then all nodes under this node are also collapsed, and hence invisible. I cannot think of any situation where a node is collapsed, but one of its child node or grandchild node is expanded.
Thanks
Sunil
I am really sorry. But I appreciate all your efforts greatly.
I will create a project using latest version and post it here.
I am dynamically changing the height/width of tree as I expand and collapse a node.
So if I collapse a node, its children are no more visible. So why would I need to know how much height and width, these invisible nodes are occupying? If a node is collapsed, then all nodes under this node are also collapsed, and hence invisible. I cannot think of any situation where a node is collapsed, but one of its child node or grandchild node is expanded.
Thanks
Sunil
0
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
answered on 12 Dec 2010, 09:36 PM
Hi Richard,
Another thing I need to mention and that is, the recursion method only looks at children of the node passed as a parameter, and not all tree nodes. There might be other nodes below the passed node as you said , which could be expanded and are at the SAME LEVEL as the passed node.
Thanks
Sunil
Another thing I need to mention and that is, the recursion method only looks at children of the node passed as a parameter, and not all tree nodes. There might be other nodes below the passed node as you said , which could be expanded and are at the SAME LEVEL as the passed node.
Thanks
Sunil
0
Richard Slade
Top achievements
Rank 2
answered on 12 Dec 2010, 09:39 PM
Hi Sunil,
Don't be sorry, it's maybe me. No, I can see that you wouldn't want to get anything under a node that is not expanded, but there are other nodes at the same level that are, or could be expanded and you've already returned how wide it should be without considering those (I think)
Node 1 (not expanded) - return the right bounds of this node
Node 2 (not expanded)
Node 3 (expanded)
Node 3 A (expanded)
Node 3 B (expanded) - we want the right bounds of this node
Node 4 (not expanded)
Regards,
Richard
Don't be sorry, it's maybe me. No, I can see that you wouldn't want to get anything under a node that is not expanded, but there are other nodes at the same level that are, or could be expanded and you've already returned how wide it should be without considering those (I think)
Node 1 (not expanded) - return the right bounds of this node
Node 2 (not expanded)
Node 3 (expanded)
Node 3 A (expanded)
Node 3 B (expanded) - we want the right bounds of this node
Node 4 (not expanded)
Regards,
Richard
0
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
answered on 12 Dec 2010, 09:56 PM
Hi Richard,
If you look closely at the recursion function, you will see that for nodes that are expanded and at the SAME LEVEL, the recursion function is being fully executed i.e.we are not returning from the function without inspecting all its child nodes.
In the case you have mentioned the nodes NODE1, NODE2 and NODE4 will be return from recursion function based on 'if (!node.Expanded) statement' without any further inspection of their children.
However, nodes NODE 3, NODE 3A and NODE 3B would all be inspected in detail.
So any expanded node is not going to be missed by the recursion function.
Thanks
Sunil
If you look closely at the recursion function, you will see that for nodes that are expanded and at the SAME LEVEL, the recursion function is being fully executed i.e.we are not returning from the function without inspecting all its child nodes.
In the case you have mentioned the nodes NODE1, NODE2 and NODE4 will be return from recursion function based on 'if (!node.Expanded) statement' without any further inspection of their children.
However, nodes NODE 3, NODE 3A and NODE 3B would all be inspected in detail.
So any expanded node is not going to be missed by the recursion function.
Thanks
Sunil
0
Richard Slade
Top achievements
Rank 2
answered on 12 Dec 2010, 10:04 PM
Hi,
Yes, you're right. I see that now. Thanks.
But I still can't get it to work with the latest version. I have got a version to work in C# but I haven't got it quite right yet and I can't say it's any faster.
I'll post if I can get it going
Richard
Yes, you're right. I see that now. Thanks.
But I still can't get it to work with the latest version. I have got a version to work in C# but I haven't got it quite right yet and I can't say it's any faster.
I'll post if I can get it going
Richard
0
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
answered on 12 Dec 2010, 10:05 PM
Hi Richard,
The loop mentioned below, which is a part of the recursion function, inspects all nodes at the same level, whether they are expanded or collapsed.
Thanks
Sunil
The loop mentioned below, which is a part of the recursion function, inspects all nodes at the same level, whether they are expanded or collapsed.
foreach (RadTreeNode n in node.Nodes)//ALL NODES at same LEVEL considered by this loop
{ maxRight = Math.Max(maxRight, GetMaxRight(n)); }Thanks
Sunil
0
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
answered on 12 Dec 2010, 10:11 PM
Hi Richard,
In the AfterCollapse and AfterExpand events, I am using the following code.
The methods for removing scrollbar
This means the methods can quickly calculate the optimal width and height for a treeview when you want no scrollbars to show for the treeview. Make sure you don't pass a step value of 1 but 100 or 50 to get best performance from the methods -
Thanks
Sunil
Calling the VanishHorizontalScroll and VanishVerticalSctoll Methods
In the AfterCollapse and AfterExpand events, I am using the following code.
The methods for removing scrollbar
s are- VanishHorizonatalScroll and VanishVerticalScroll, which calculate the closest treeview's width and height upto 5 pixels or 1 pixel accuracy, with very few iterations. Normally if you want to find the width and height within 1 pixel accuracy you might end up going through 300 or 400 iterations. But using the methods below, you would accomplish the same with about 5 iterations, provided you pass a value of 100 or 50 for the 'step' parameter in these methods.This means the methods can quickly calculate the optimal width and height for a treeview when you want no scrollbars to show for the treeview. Make sure you don't pass a step value of 1 but 100 or 50 to get best performance from the methods -
VanishHorizonatalScroll and VanishVerticalScroll.Thanks
Sunil
Methods - VanishHorizonatalScroll and VanishVerticalScrollprivate void VanishVerticalScroll(RadTreeView tree, int step) { if (tree.VScrollBar.Visible) { while (tree.VScrollBar.Visible) { tree.Height = tree.Height + step; } //use a lower step value that is one-fifth original value //to further get a more exact treeview width and height step = step - (step % 5); if (step == 1 || step <= 5) { return; } //repeatedly use a lower step value that is one-fifth //of original value, so we get accuracy and minimize //total number of iterations //accuracy is to nearest 5 pixels while (step>=5) { step = step / 5; VanishVerticalScroll(tree, step); step = step - (step % 5); } //FINALLY get accuracy upto 1 pixels VanishVerticalScroll(tree, 1); } else if (tree.VScrollBar.Visible == false) { while (tree.VScrollBar.Visible == false) { tree.Height = tree.Height - step; } tree.Height = tree.Height + step ; //use a lower step value that is one-fifth original value //to further get a more exact treeview width and height step = step - (step % 5); if (step == 1 || step <= 5) { return; } //repeatedly use a lower step value that is one-fifth //of original value, so we get accuracy and minimize //total number of iterations //accuracy is to nearest 5 pixels while (step >= 5 ) { step = step / 5; VanishVerticalScroll(tree, step); step = step - (step % 5); } //FINALLY get accuracy upto 1 pixels VanishVerticalScroll(tree, 1); } } private void VanishHorizonatalScroll(RadTreeView tree, int step) { if (tree.HScrollBar.Visible) { while (tree.HScrollBar.Visible) { tree.Width = tree.Width + step; } //use a lower step value that is one-fifth original value //to further get a more exact treeview width and height step = step - (step % 5); if (step == 1 || step<=5) { return; } //repeatedly use a lower step value that is one-fifth //of original value, so we get accuracy and minimize //total number of iterations //accuracy is to nearest 5 pixels while (step >=5 ) { step = step / 5; VanishHorizonatalScroll(tree, step); step = step - (step % 5); } //FINALLY get accuracy upto 1 pixels VanishHorizonatalScroll(tree, 1); } else if (tree.HScrollBar.Visible == false) { while (tree.HScrollBar.Visible == false) { tree.Width = tree.Width - step; } tree.Width = tree.Width + step; //use a lower step value that is one-fifth original value //to further get a more exact treeview width and height step = step - (step % 5); if (step == 1 || step <= 5) { return; } //repeatedly use a lower step value that is one-fifth //of original value, so we get accuracy and minimize //total number of iterations. //accuracy is to nearest 5 pixels while (step >=5) { step = step / 5; VanishHorizonatalScroll(tree, step); step = step - (step % 5); } //FINALLY get accuracy upto 1 pixels VanishHorizonatalScroll(tree, 1); } }Calling the VanishHorizontalScroll and VanishVerticalSctoll Methods
private void bomRadTreeView_AfterCollapse(object sender, RadTreeViewEventArgs e) { //resize main BOM tree and also synschronize all the heights VanishHorizonatalScroll(bomRadTreeView, 100); VanishVerticalScroll(bomRadTreeView, 100); }private void bomRadTreeView_AfterExpand(object sender, RadTreeViewEventArgs e) { //resize main BOM tree and also synschronize all the heights VanishHorizonatalScroll(bomRadTreeView, 100); VanishVerticalScroll(bomRadTreeView, 100); } 0
Accepted
Richard Slade
Top achievements
Rank 2
answered on 12 Dec 2010, 10:14 PM
Hi Sunil,
Ok, this is looking pretty good to me. Have a look at this movie for performance and the code below. You will probably have to alter a few bits for the earlier version, but fingers crossed!
Code File:
Designer File
Let me know if that's any good
Richard
Ok, this is looking pretty good to me. Have a look at this movie for performance and the code below. You will probably have to alter a few bits for the earlier version, but fingers crossed!
Code File:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using Telerik.WinControls.UI; using System.Collections.ObjectModel; namespace RadTreeView_C { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { this.radTreeView1.Height = GetMaxBottom(); this.radTreeView1.Width = GetMaxRight(); } private int GetMaxBottom() { int maxBottom = 0; foreach (RadTreeNode node in GetRadTreeNodes(this.radTreeView1.Nodes)) { if (node.Bounds.Bottom > maxBottom) { maxBottom = node.Bounds.Bottom; } } return maxBottom + 2; } private int GetMaxRight() { int maxRight = 0; foreach (RadTreeNode node in GetRadTreeNodes(this.radTreeView1.Nodes)) { if (node.Bounds.Right > maxRight) { maxRight = node.Bounds.Right; } } return maxRight + 2; } public static ReadOnlyCollection<RadTreeNode> GetRadTreeNodes(Telerik.WinControls.UI.RadTreeNodeCollection nodes) { List<RadTreeNode> returnNodes = new List<RadTreeNode>(); foreach (RadTreeNode node in nodes) { returnNodes.Add(node); if (node.Expanded) { ReadOnlyCollection<RadTreeNode> subNodes = GetRadTreeNodes(node.Nodes); returnNodes.AddRange(subNodes); } } ReadOnlyCollection<RadTreeNode> readOnlyNodes = new ReadOnlyCollection<RadTreeNode>(returnNodes); return readOnlyNodes; } private void radDropDownList1_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e) { switch (this.radDropDownList1.SelectedIndex) { case 0: this.radTreeView1.Nodes.Clear(); for (int i = 0; i <= 4; i++) { this.radTreeView1.Nodes.Add(i.ToString()); } foreach (RadTreeNode node in this.radTreeView1.Nodes) { node.Nodes.Add("Some Node"); foreach (RadTreeNode node1 in node.Nodes) { node1.Nodes.Add("Some Node"); foreach (RadTreeNode node2 in node.Nodes) { node2.Nodes.Add("Some Node"); } } } SetSize(); break; case 1: this.radTreeView1.Nodes.Clear(); for (int i = 0; i <= 4; i++) { this.radTreeView1.Nodes.Add(i.ToString()); } foreach (RadTreeNode node in this.radTreeView1.Nodes) { node.Nodes.Add("Some Node"); foreach (RadTreeNode node1 in node.Nodes) { node1.Nodes.Add("Some Node"); foreach (RadTreeNode node2 in node1.Nodes) { node2.Nodes.Add("Some Node"); foreach (RadTreeNode node3 in node2.Nodes) { node3.Nodes.Add("Some Node"); foreach (RadTreeNode node4 in node3.Nodes) { node4.Nodes.Add("Some Node"); foreach (RadTreeNode node5 in node4.Nodes) { node5.Nodes.Add("Some Node"); foreach (RadTreeNode node6 in node5.Nodes) { node6.Nodes.Add("Some Node"); foreach (RadTreeNode node7 in node6.Nodes) { node7.Nodes.Add("Some Node"); foreach (RadTreeNode node8 in node7.Nodes) { node8.Nodes.Add("Some Node"); foreach (RadTreeNode node9 in node8.Nodes) { node9.Nodes.Add("Some Node"); } } } } } } } } } } SetSize(); break; case 2: this.radTreeView1.Nodes.Clear(); for (int i = 0; i <= 4; i++) { this.radTreeView1.Nodes.Add(i.ToString()); } foreach (RadTreeNode node in this.radTreeView1.Nodes) { node.Nodes.Add("Some Node"); foreach (RadTreeNode node1 in node.Nodes) { node1.Nodes.Add("Some Node"); foreach (RadTreeNode node2 in node1.Nodes) { node2.Nodes.Add("Some Node"); foreach (RadTreeNode node3 in node2.Nodes) { node3.Nodes.Add("Some Node"); } } } } SetSize(); break; } } private void radTreeView1_NodeExpandedChanged(object sender, RadTreeViewEventArgs e) { SetSize(); } private void SetSize() { this.radTreeView1.Height = GetMaxBottom(); this.radTreeView1.Width = GetMaxRight(); this.radTreeView1.VScrollBar.Visible = false; this.radTreeView1.HScrollBar.Visible = false; } } } Designer File
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Partial Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. <System.Diagnostics.DebuggerNonUserCode()> _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) Try If disposing AndAlso components IsNot Nothing Then components.Dispose() End If Finally MyBase.Dispose(disposing) End Try End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. <System.Diagnostics.DebuggerStepThrough()> _ Private Sub InitializeComponent() Dim RadTreeNode1 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode2 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode3 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode4 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode5 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode6 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode7 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode8 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode9 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode10 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode11 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode12 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode13 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode14 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode15 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode16 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode17 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode18 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode19 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode20 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode21 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode22 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode23 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode24 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode25 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode26 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode27 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode28 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode29 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode30 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode31 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode32 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode33 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode34 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadTreeNode35 As Telerik.WinControls.UI.RadTreeNode = New Telerik.WinControls.UI.RadTreeNode() Dim RadListDataItem1 As Telerik.WinControls.UI.RadListDataItem = New Telerik.WinControls.UI.RadListDataItem() Dim RadListDataItem2 As Telerik.WinControls.UI.RadListDataItem = New Telerik.WinControls.UI.RadListDataItem() Dim RadListDataItem3 As Telerik.WinControls.UI.RadListDataItem = New Telerik.WinControls.UI.RadListDataItem() Me.RadTreeView1 = New Telerik.WinControls.UI.RadTreeView() Me.RadDropDownList1 = New Telerik.WinControls.UI.RadDropDownList() CType(Me.RadTreeView1, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.RadDropDownList1, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' 'RadTreeView1 ' Me.RadTreeView1.BackColor = System.Drawing.SystemColors.Window Me.RadTreeView1.CheckBoxes = True Me.RadTreeView1.Cursor = System.Windows.Forms.Cursors.Default Me.RadTreeView1.Font = New System.Drawing.Font("Segoe UI", 8.25!) Me.RadTreeView1.ForeColor = System.Drawing.Color.Black Me.RadTreeView1.Location = New System.Drawing.Point(0, 0) Me.RadTreeView1.Name = "RadTreeView1" RadTreeNode2.ShowCheckBox = True RadTreeNode2.Text = "Node5" RadTreeNode4.ShowCheckBox = True RadTreeNode4.Text = "Node7" RadTreeNode6.ShowCheckBox = True RadTreeNode6.Text = "Node9" RadTreeNode7.ShowCheckBox = True RadTreeNode7.Text = "Node10" RadTreeNode5.Nodes.Add(RadTreeNode6) RadTreeNode5.Nodes.Add(RadTreeNode7) RadTreeNode5.ShowCheckBox = True RadTreeNode5.Text = "Node8" RadTreeNode3.Nodes.Add(RadTreeNode4) RadTreeNode3.Nodes.Add(RadTreeNode5) RadTreeNode3.ShowCheckBox = True RadTreeNode3.Text = "Node6" RadTreeNode1.Nodes.Add(RadTreeNode2) RadTreeNode1.Nodes.Add(RadTreeNode3) RadTreeNode1.ShowCheckBox = True RadTreeNode1.Text = "Node1" RadTreeNode9.ShowCheckBox = True RadTreeNode9.Text = "Node11" RadTreeNode11.ShowCheckBox = True RadTreeNode11.Text = "Node13" RadTreeNode12.ShowCheckBox = True RadTreeNode12.Text = "Node14" RadTreeNode10.Nodes.Add(RadTreeNode11) RadTreeNode10.Nodes.Add(RadTreeNode12) RadTreeNode10.ShowCheckBox = True RadTreeNode10.Text = "Node12" RadTreeNode8.Nodes.Add(RadTreeNode9) RadTreeNode8.Nodes.Add(RadTreeNode10) RadTreeNode8.ShowCheckBox = True RadTreeNode8.Text = "Node2" RadTreeNode14.ShowCheckBox = True RadTreeNode14.Text = "Node15" RadTreeNode15.ShowCheckBox = True RadTreeNode15.Text = "Node16" RadTreeNode13.Nodes.Add(RadTreeNode14) RadTreeNode13.Nodes.Add(RadTreeNode15) RadTreeNode13.ShowCheckBox = True RadTreeNode13.Text = "Node3" RadTreeNode17.ShowCheckBox = True RadTreeNode17.Text = "Node17" RadTreeNode18.ShowCheckBox = True RadTreeNode18.Text = "Node18" RadTreeNode16.Nodes.Add(RadTreeNode17) RadTreeNode16.Nodes.Add(RadTreeNode18) RadTreeNode16.ShowCheckBox = True RadTreeNode16.Text = "Node4" RadTreeNode19.ShowCheckBox = True RadTreeNode19.Text = "Node19" RadTreeNode20.Expanded = True RadTreeNode21.ShowCheckBox = True RadTreeNode21.Text = "Node22" RadTreeNode22.Expanded = True RadTreeNode23.ShowCheckBox = True RadTreeNode23.Text = "Node25" RadTreeNode24.Expanded = True RadTreeNode25.ShowCheckBox = True RadTreeNode25.Text = "Node28" RadTreeNode26.Expanded = True RadTreeNode27.ShowCheckBox = True RadTreeNode27.Text = "Node31" RadTreeNode28.ShowCheckBox = True RadTreeNode28.Text = "Node32" RadTreeNode29.Expanded = True RadTreeNode30.Expanded = True RadTreeNode31.ShowCheckBox = True RadTreeNode31.Text = "Node35" RadTreeNode30.Nodes.Add(RadTreeNode31) RadTreeNode30.ShowCheckBox = True RadTreeNode30.Text = "Node34" RadTreeNode29.Nodes.Add(RadTreeNode30) RadTreeNode29.ShowCheckBox = True RadTreeNode29.Text = "Node33" RadTreeNode26.Nodes.Add(RadTreeNode27) RadTreeNode26.Nodes.Add(RadTreeNode28) RadTreeNode26.Nodes.Add(RadTreeNode29) RadTreeNode26.ShowCheckBox = True RadTreeNode26.Text = "Node29" RadTreeNode32.ShowCheckBox = True RadTreeNode32.Text = "Node30" RadTreeNode24.Nodes.Add(RadTreeNode25) RadTreeNode24.Nodes.Add(RadTreeNode26) RadTreeNode24.Nodes.Add(RadTreeNode32) RadTreeNode24.ShowCheckBox = True RadTreeNode24.Text = "Node26" RadTreeNode33.ShowCheckBox = True RadTreeNode33.Text = "Node27" RadTreeNode22.Nodes.Add(RadTreeNode23) RadTreeNode22.Nodes.Add(RadTreeNode24) RadTreeNode22.Nodes.Add(RadTreeNode33) RadTreeNode22.ShowCheckBox = True RadTreeNode22.Text = "Node23" RadTreeNode34.ShowCheckBox = True RadTreeNode34.Text = "Node24" RadTreeNode20.Nodes.Add(RadTreeNode21) RadTreeNode20.Nodes.Add(RadTreeNode22) RadTreeNode20.Nodes.Add(RadTreeNode34) RadTreeNode20.ShowCheckBox = True RadTreeNode20.Text = "Node20" RadTreeNode35.ShowCheckBox = True RadTreeNode35.Text = "Node21" Me.RadTreeView1.Nodes.Add(RadTreeNode1) Me.RadTreeView1.Nodes.Add(RadTreeNode8) Me.RadTreeView1.Nodes.Add(RadTreeNode13) Me.RadTreeView1.Nodes.Add(RadTreeNode16) Me.RadTreeView1.Nodes.Add(RadTreeNode19) Me.RadTreeView1.Nodes.Add(RadTreeNode20) Me.RadTreeView1.Nodes.Add(RadTreeNode35) Me.RadTreeView1.RightToLeft = System.Windows.Forms.RightToLeft.No ' ' ' Me.RadTreeView1.RootElement.ForeColor = System.Drawing.Color.Black Me.RadTreeView1.RootRelationDisplayName = "The Name" Me.RadTreeView1.ShowLines = True Me.RadTreeView1.ShowRootLines = False Me.RadTreeView1.Size = New System.Drawing.Size(400, 158) Me.RadTreeView1.TabIndex = 0 Me.RadTreeView1.Text = "RadTreeView1" CType(Me.RadTreeView1.GetChildAt(0), Telerik.WinControls.UI.RadTreeViewElement).ItemHeight = 16 CType(Me.RadTreeView1.GetChildAt(0), Telerik.WinControls.UI.RadTreeViewElement).ShowRootLines = False CType(Me.RadTreeView1.GetChildAt(0), Telerik.WinControls.UI.RadTreeViewElement).ShowExpandCollapse = True CType(Me.RadTreeView1.GetChildAt(0), Telerik.WinControls.UI.RadTreeViewElement).AllowArbitraryItemHeight = False CType(Me.RadTreeView1.GetChildAt(0), Telerik.WinControls.UI.RadTreeViewElement).NodeSpacing = 0 CType(Me.RadTreeView1.GetChildAt(0), Telerik.WinControls.UI.RadTreeViewElement).TreeIndent = 20 CType(Me.RadTreeView1.GetChildAt(0), Telerik.WinControls.UI.RadTreeViewElement).LineColor = System.Drawing.SystemColors.ControlDark CType(Me.RadTreeView1.GetChildAt(0), Telerik.WinControls.UI.RadTreeViewElement).ShowLines = True CType(Me.RadTreeView1.GetChildAt(0), Telerik.WinControls.UI.RadTreeViewElement).FullRowSelect = False CType(Me.RadTreeView1.GetChildAt(0), Telerik.WinControls.UI.RadTreeViewElement).BackColor = System.Drawing.SystemColors.Window ' 'RadDropDownList1 ' Me.RadDropDownList1.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDownList RadListDataItem1.Text = "ListItem 1" RadListDataItem1.TextWrap = True RadListDataItem2.Text = "ListItem 2" RadListDataItem2.TextWrap = True RadListDataItem3.Text = "ListItem 3" RadListDataItem3.TextWrap = True Me.RadDropDownList1.Items.Add(RadListDataItem1) Me.RadDropDownList1.Items.Add(RadListDataItem2) Me.RadDropDownList1.Items.Add(RadListDataItem3) Me.RadDropDownList1.Location = New System.Drawing.Point(485, 479) Me.RadDropDownList1.Name = "RadDropDownList1" Me.RadDropDownList1.Size = New System.Drawing.Size(158, 22) Me.RadDropDownList1.TabIndex = 1 ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(687, 602) Me.Controls.Add(Me.RadDropDownList1) Me.Controls.Add(Me.RadTreeView1) Me.Name = "Form1" Me.Text = "Form1" CType(Me.RadTreeView1, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.RadDropDownList1, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) Me.PerformLayout() End Sub Friend WithEvents RadTreeView1 As Telerik.WinControls.UI.RadTreeView Friend WithEvents RadDropDownList1 As Telerik.WinControls.UI.RadDropDownList End Class Let me know if that's any good
Richard
0
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
answered on 12 Dec 2010, 10:22 PM
Hi Richard,
That looks impressive.
But did you try collapsing a node that had 3 or more levels under it, with each level having about 5 nodes. I will try to post the movie of what performance I am seeing based on code I just posted.
Anyways, I am going to get your sample code and give it a spin.
Thanks
Sunil
That looks impressive.
But did you try collapsing a node that had 3 or more levels under it, with each level having about 5 nodes. I will try to post the movie of what performance I am seeing based on code I just posted.
Anyways, I am going to get your sample code and give it a spin.
Thanks
Sunil
0
Richard Slade
Top achievements
Rank 2
answered on 12 Dec 2010, 10:29 PM
Hi Sunil,
I've tried lots of combinations and it's looking pretty ok. I can't make a scrollbar appear and it seems to go quickly under all circumstances at the moment. Limited testing of course, but it's better than my first try with controlling the scrollbars.
I'll be very interested to know how it seems on yours. For video by the way, i'm using Jing if that helps
richard
I've tried lots of combinations and it's looking pretty ok. I can't make a scrollbar appear and it seems to go quickly under all circumstances at the moment. Limited testing of course, but it's better than my first try with controlling the scrollbars.
I'll be very interested to know how it seems on yours. For video by the way, i'm using Jing if that helps
richard
0
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
answered on 12 Dec 2010, 10:33 PM
Hi Richard,
Using the code I just posted, I am getting the performance as in the video below. I will try your code later and let you know.
BOMRadTree Resizing Performance
Thanks
Sunil
Using the code I just posted, I am getting the performance as in the video below. I will try your code later and let you know.
BOMRadTree Resizing Performance
Thanks
Sunil
0
Richard Slade
Top achievements
Rank 2
answered on 12 Dec 2010, 10:40 PM
Hi Sunil,
Yes, I can see that it had some performance issues. Perhaps the one I posted might help. I do hope so for you.
Look forward to hearing back from you.
Richard
Yes, I can see that it had some performance issues. Perhaps the one I posted might help. I do hope so for you.
Look forward to hearing back from you.
Richard
0
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
answered on 12 Dec 2010, 11:08 PM
Hi Richard,
I have some questions after reading your code.
Thanks
Sunil
I have some questions after reading your code.
- Before you get maxright and maxbottom, you are getting all nodes in a single LIST<>. Right? That means all children, grandchildren etc are in the same flat List<>.
- What is the purpose of adding a 2 before returning a value from GetMaxRigth or GetMaxBottom methods?
Thanks
Sunil
0
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
answered on 12 Dec 2010, 11:32 PM
Hi Richard,
I tried your approach where you add a 2 always to maxRight or maxBottom, but it gives me scroll bars.
The performance is definitely better, but somewhere we are missing the exact number that needs to be added as extra to a Right or Bottom of a node.
BOMRadTree Resizing Performance with your New Approach
Thanks
Sunil
I tried your approach where you add a 2 always to maxRight or maxBottom, but it gives me scroll bars.
The performance is definitely better, but somewhere we are missing the exact number that needs to be added as extra to a Right or Bottom of a node.
BOMRadTree Resizing Performance with your New Approach
Thanks
Sunil
0
Richard Slade
Top achievements
Rank 2
answered on 12 Dec 2010, 11:40 PM
Hi Sunil,
I think we are getting into a differences now between version as the SetSize method always sets the scrollbars visibility to false.
Yes, I am getting a flattened list of nodes, but only adding in the ones that are expanded so cutting down on the ones that need to be inspected.
The purpose of always adding 2 onto the end was just for a little padding so it wasn't squashed. But the value without the 2 padding would have been fine.
With my final approach, it always finds the correct size (in the latest version of RadTreeView) and doesn't show scrollbars at any level. Have you tried the newest version of the code I posted yet?
Hope that helps
Richard
I think we are getting into a differences now between version as the SetSize method always sets the scrollbars visibility to false.
Yes, I am getting a flattened list of nodes, but only adding in the ones that are expanded so cutting down on the ones that need to be inspected.
The purpose of always adding 2 onto the end was just for a little padding so it wasn't squashed. But the value without the 2 padding would have been fine.
With my final approach, it always finds the correct size (in the latest version of RadTreeView) and doesn't show scrollbars at any level. Have you tried the newest version of the code I posted yet?
Hope that helps
Richard
0
Richard Slade
Top achievements
Rank 2
answered on 12 Dec 2010, 11:46 PM
Sunil,
Also remember on mine you may need to change Bounds to LabelBounds for your older RadControls version.
Richard
Also remember on mine you may need to change Bounds to LabelBounds for your older RadControls version.
Richard
0
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
answered on 13 Dec 2010, 12:15 AM
Hi Richard,
I will try using LabelBounds in the version I am using.
Your initial approach combined with the modifications for fewer iterations that I added, was very sound and would work in all versions, it seems.
Thanks
Sunil
I will try using LabelBounds in the version I am using.
Your initial approach combined with the modifications for fewer iterations that I added, was very sound and would work in all versions, it seems.
Thanks
Sunil
0
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
answered on 13 Dec 2010, 12:22 AM
Hi Richard,
I tried your approach using LabelBounds instead of Bounds but still I get scrollbars as posted in an earlier post.
Thanks
Sunil
I tried your approach using LabelBounds instead of Bounds but still I get scrollbars as posted in an earlier post.
Thanks
Sunil
0
Richard Slade
Top achievements
Rank 2
answered on 13 Dec 2010, 12:28 AM
Hi Sunil,
It looks like now any further attempts for me to modify this aren't going to be as good as the version that you now have. Probably due to the fact that we are using different versions of the controls. I'm glad though that I could help and hope that you've found this useful. I'd only ask that you mark the posts that you found most useful as answer.
If you have any further questions though, do just let me know.
All the best
Speak soon
Richard
It looks like now any further attempts for me to modify this aren't going to be as good as the version that you now have. Probably due to the fact that we are using different versions of the controls. I'm glad though that I could help and hope that you've found this useful. I'd only ask that you mark the posts that you found most useful as answer.
If you have any further questions though, do just let me know.
All the best
Speak soon
Richard
0
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
answered on 13 Dec 2010, 12:37 AM
Hi Richard,
Yes I agree with you.
I appreciate all your help in getting this problem solved.
In my version of Q1 2008 SP1, the approach that works is your first approach ( first marked answer) combined with the modifications I made for drastically decreasing the number of iterations. Look for 'VanishHorizonatalScroll(bomRadTreeView, 100);' to see the post that outlines this approach.
Thanks a lot
Sunil
Yes I agree with you.
I appreciate all your help in getting this problem solved.
In my version of Q1 2008 SP1, the approach that works is your first approach ( first marked answer) combined with the modifications I made for drastically decreasing the number of iterations. Look for 'VanishHorizonatalScroll(bomRadTreeView, 100);' to see the post that outlines this approach.
Thanks a lot
Sunil