thor918
asked on
treeview ahhhhhh?
I need a sorting code that work like this:
I have two variable values X & Y. I need to get them listed in this order with the smallest value first in a treeview list. The Y Values must be sorted by the X values.
*************** Example ***************
Treeview list:
X------+----Y
| |
| +----Y
| |
| +----Y
|
X-----+---Y
| |
| +---Y
| |
| +---Y
|
|
X-----+----Y
|
+---Y
Treeview list with values:
1------+----12
| |
| +----54
| |
| +----84
|
2-----+---1
| |
| +---2
| |
| +---3
|
|
3-----+----45
|
+---100
After this I need to put the values from the treeview to two listbox'es
Like this:
X Y
************ ************
* Listbox1 * * Listbox1 *
************ ************
* 1 * * 12 *
* 1 * * 54 *
* 1 * * 84 *
* 2 * * 1 *
* 2 * * 2 *
* 2 * * 3 *
* 3 * * 45 *
* 3 * * 100 *
************ ************
It must be easy to add new X & Y values in the treeview list. And every time
new values are added they must be sorted in the same order. The small first.
Thanks
I have two variable values X & Y. I need to get them listed in this order with the smallest value first in a treeview list. The Y Values must be sorted by the X values.
*************** Example ***************
Treeview list:
X------+----Y
| |
| +----Y
| |
| +----Y
|
X-----+---Y
| |
| +---Y
| |
| +---Y
|
|
X-----+----Y
|
+---Y
Treeview list with values:
1------+----12
| |
| +----54
| |
| +----84
|
2-----+---1
| |
| +---2
| |
| +---3
|
|
3-----+----45
|
+---100
After this I need to put the values from the treeview to two listbox'es
Like this:
X Y
************ ************
* Listbox1 * * Listbox1 *
************ ************
* 1 * * 12 *
* 1 * * 54 *
* 1 * * 84 *
* 2 * * 1 *
* 2 * * 2 *
* 2 * * 3 *
* 3 * * 45 *
* 3 * * 100 *
************ ************
It must be easy to add new X & Y values in the treeview list. And every time
new values are added they must be sorted in the same order. The small first.
Thanks
ASKER
Adjusted points from 200 to 400
ASKER
Nice. I going to try it at once!
ASKER
I don't get the code you posted to work angelIII...
TreeView.Nodes.Root.FirstS ibling
There's no root under nodes
TreeView.Nodes.Root.FirstS
There's no root under nodes
ASKER
e-mail me at
thor918@postkassa.no
thor918@postkassa.no
uups (this is because i typed the code directly here...) shame on me...
TreeView.Nodes(1).Root.Fir stSibling
TreeView.Nodes(1).Root.Fir
ASKER
is someone want's to send me examples send it on my e-mail
ASKER
okey. going to try it once more.
later...
later...
ASKER
okey. going to try it once more.
later...
later...
Hi,
First set the treeview.sorterd property true. Whenever adding a node, set that node.sorted=true. This will sort the values in a way u like. if ur having a numeric values to be sorterd prfix it blank spcces or zero for the length u want.
have any clarificatons get back to me....
okay!!!!!!!!!
sample code for ur reference......
Private Sub Form_Load()
Dim x As Node
Set x = TreeView1.Nodes.Add(, , , "4")
Call TreeView1.Nodes.Add(x.Inde x, tvwChild, , "0002")
Call TreeView1.Nodes.Add(x.Inde x, tvwChild, , "0003")
Call TreeView1.Nodes.Add(x.Inde x, tvwChild, , "0001")
Call TreeView1.Nodes.Add(x.Inde x, tvwChild, , "0010")
x.Sorted = True
Call TreeView1.Nodes.Add(, , , "1")
Call TreeView1.Nodes.Add(, , , "5")
TreeView1.Sorted = True
End Sub
I hope this will work out for u
Cheers
rbsubra
(*_*)
First set the treeview.sorterd property true. Whenever adding a node, set that node.sorted=true. This will sort the values in a way u like. if ur having a numeric values to be sorterd prfix it blank spcces or zero for the length u want.
have any clarificatons get back to me....
okay!!!!!!!!!
sample code for ur reference......
Private Sub Form_Load()
Dim x As Node
Set x = TreeView1.Nodes.Add(, , , "4")
Call TreeView1.Nodes.Add(x.Inde
Call TreeView1.Nodes.Add(x.Inde
Call TreeView1.Nodes.Add(x.Inde
Call TreeView1.Nodes.Add(x.Inde
x.Sorted = True
Call TreeView1.Nodes.Add(, , , "1")
Call TreeView1.Nodes.Add(, , , "5")
TreeView1.Sorted = True
End Sub
I hope this will work out for u
Cheers
rbsubra
(*_*)
ASKER
Thanks.
That worked.
But how do you add one value under the same X node. And how do you prevent that there is not more of the same value?
regards
That worked.
But how do you add one value under the same X node. And how do you prevent that there is not more of the same value?
regards
Hey,
its so simple...........
have a look at this
Private Sub Form_Load()
AddNode 1, 2
AddNode 1, 3
AddNode 3, 1
AddNode 4, 1
End Sub
Private Function AddNode(x As String, y As String)
Dim nodeX As Node
Dim relNode As Node
If TreeView1.Nodes.Count > 0 Then
Set nodeX = TreeView1.Nodes(1)
Do While (nodeX Is Nothing) = False
If nodeX.Text = x Then
Set relNode = nodeX
Set nodeX = Nothing
Else
Set nodeX = nodeX.Next
End If
Loop
End If
If relNode Is Nothing Then
Set relNode = TreeView1.Nodes.Add(, , , x)
End If
Call TreeView1.Nodes.Add(relNod e, tvwChild, , y)
TreeView1.Sorted = True
relNode.Sorted = True
End Function
its so simple...........
have a look at this
Private Sub Form_Load()
AddNode 1, 2
AddNode 1, 3
AddNode 3, 1
AddNode 4, 1
End Sub
Private Function AddNode(x As String, y As String)
Dim nodeX As Node
Dim relNode As Node
If TreeView1.Nodes.Count > 0 Then
Set nodeX = TreeView1.Nodes(1)
Do While (nodeX Is Nothing) = False
If nodeX.Text = x Then
Set relNode = nodeX
Set nodeX = Nothing
Else
Set nodeX = nodeX.Next
End If
Loop
End If
If relNode Is Nothing Then
Set relNode = TreeView1.Nodes.Add(, , , x)
End If
Call TreeView1.Nodes.Add(relNod
TreeView1.Sorted = True
relNode.Sorted = True
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
For your children, you need to change the .Sorted Property of your X nodes to true
To fill your Listboxes, simply do this:
DIM nodParent as Node
DIM nodChild as Node
SET nodParent = TreeView.Nodes.Root.FirstS
WHILE NOT( nodParent IS NOTHING )
SET nodChild = nodParent.Child
WHILE NOT (nodChild IS NOTHING)
List1.Add nodParent.Text
List2.Add nodChild.Text
Set nodChild = nodCHild.Next
WEND
SET nodParent = nodParent.Next
WEND
Good luck