hakanogu
asked on
Treeview to RichTextBox import
Hello,
I have a small project. In one point I couldnt succed to solve again.
In my project , I have one treeview ( called tv ), and one command button. In my project in Form_Load event , I have some INFITF application codes which provides some information to establish treeview.
ın the attachment , I can export treeview nodes in order to Richtext box, no problem. But when I am importing to richtextbox, I need some additional events.
What I want:
- when I am sending the treeview nodes to Richtext box, I want to add some suffix to treeview nodes.
If my node has sub nodes - when I am sending , I want to add (.Zeta) suffix at the end, and if there is sub nodes ı want to add (.Beta) suffix at the ends.
For example lets say that my treeview like that
-AA
.
.
-BB
.BB1
.BB2
.
.
-CC
.CC1
.CC2
.
.DD
.
.EE
And my Richtextbox:
AA
BB
BB1
BB2
CC
CC1
CC2
DD
EE
The thing that I want:
AA.Zeta
BB.Zeta
BB1.Beta
BB2.Beta
CC.Zeta
CC1.Beta
CC2.Beta
DD.Beta
EE.Beta
ı am attaching to my project, but I deleted my form_load event because of my INFITF application which will not work on your computer. So you can write some thing there to establih your treeview.
Can you help me for this point?
Project.zip
I have a small project. In one point I couldnt succed to solve again.
In my project , I have one treeview ( called tv ), and one command button. In my project in Form_Load event , I have some INFITF application codes which provides some information to establish treeview.
ın the attachment , I can export treeview nodes in order to Richtext box, no problem. But when I am importing to richtextbox, I need some additional events.
What I want:
- when I am sending the treeview nodes to Richtext box, I want to add some suffix to treeview nodes.
If my node has sub nodes - when I am sending , I want to add (.Zeta) suffix at the end, and if there is sub nodes ı want to add (.Beta) suffix at the ends.
For example lets say that my treeview like that
-AA
.
.
-BB
.BB1
.BB2
.
.
-CC
.CC1
.CC2
.
.DD
.
.EE
And my Richtextbox:
AA
BB
BB1
BB2
CC
CC1
CC2
DD
EE
The thing that I want:
AA.Zeta
BB.Zeta
BB1.Beta
BB2.Beta
CC.Zeta
CC1.Beta
CC2.Beta
DD.Beta
EE.Beta
ı am attaching to my project, but I deleted my form_load event because of my INFITF application which will not work on your computer. So you can write some thing there to establih your treeview.
Can you help me for this point?
Project.zip
Let me see what I can do for you here.
Try this:
Public Sub WalkTree(objNode As Node)
'Bu kod treeviewlardaki node isimlerinin text1 kontrolunun içine atilmasini sagliyor
Dim objSiblingNode As Node
Set objSiblingNode = objNode
Do
' RichTextBox1.Text = RichTextBox1.Text & objSiblingNode.Text & vbCrLf
If objNode.Parent Is Nothing Then
RichTextBox1.Text = RichTextBox1.Text & objSiblingNode.Text & ".Zeta" & vbCrLf
Else
RichTextBox1.Text = RichTextBox1.Text & objSiblingNode.Text & ".Beta" & vbCrLf
End If
If Not objSiblingNode.Child Is Nothing Then
Call WalkTree(objSiblingNode.Child)
End If
Set objSiblingNode = objSiblingNode.Next
Loop While Not objSiblingNode Is Nothing
End Sub
ASKER
Hello Martin,
I tried the code but it just gives the root as (.Zeta), all the other is becoming (.Beta)
I tried the code but it just gives the root as (.Zeta), all the other is becoming (.Beta)
ASKER
Ok Martin i solved the problem with your help
If I correct your code instead of "objNode.Parent " with "objSiblingNode.Child" in your firs is working.
If Not objSiblingNode.Child Is Nothing Then
RichTextBox1.Text = RichTextBox1.Text & objSiblingNode.Text & ".Zeta" & vbCrLf
Else
RichTextBox1.Text = RichTextBox1.Text & objSiblingNode.Text & ".Beta" & vbCrLf
End If
If you send the new code by changing , i will accept your answer Martin.
Thank you very much for your help.
If I correct your code instead of "objNode.Parent " with "objSiblingNode.Child" in your firs is working.
If Not objSiblingNode.Child Is Nothing Then
RichTextBox1.Text = RichTextBox1.Text & objSiblingNode.Text & ".Zeta" & vbCrLf
Else
RichTextBox1.Text = RichTextBox1.Text & objSiblingNode.Text & ".Beta" & vbCrLf
End If
If you send the new code by changing , i will accept your answer Martin.
Thank you very much for your help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.