Link to home
Start Free TrialLog in
Avatar of Dumdidum
Dumdidum

asked on

Several Treeview-Questions...

Hello

I am using the Treeview-Control for my first time and I have some questions...
I have now the following Treeview:

http://www.ruttensoft.com/file/treeview.jpg

The questions:

1. How can I select "Name von eigenem Projekt" without using the mouse?
2. How can I make a new Item at "My Company"?  (at the selected item)?
3. How can I rename the selected item in the treeview itself?
4. How can I delete the selected item?

Thanks a lot in advance

Sven
ASKER CERTIFIED SOLUTION
Avatar of S-Twilley
S-Twilley

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of S-Twilley
S-Twilley

Notes:


X = AddToSelectedNode("BLAH BLAH")   ' where X is declared as a treenode
           If a node is selected, a node with text "BLAH BLAH" is added, and a reference to that new node is returned
           If no node is selected, then Nothing is returned

           If you don't need a reference to the newly added node, remove the "X = " from the code line

Y = RenameSelectedNode("BLAH BLAH")  ' where Y is declared as a boolean
           If a node is selected, it's text is changed to "BLAH BLAH".. and True is returned to express a success
           If no node is selected, then False is returned to express failure

           If you don't need to know whether it was a success or not, remove the "Y = "

Z = RenameSelectedNode()  ' where Z is declared as a boolean
           If a node is selected, it is removed (including it's child nodes).. and True is returned to express a success
           If no node is selected, then False is returned to express failure

           If you don't need to know whether it was a success or not, remove the "Z = "
sorry, that last code line was supposed to read:

Z = RemoveSelectedNode()  ' where Z is declared as a boolean
Avatar of Dumdidum

ASKER

Hi

Thanks, is it possible to rename the selected note directy in the treeview?

Like this:

http://www.ruttensoft.com/file/tree.jpg

Thanks

Sven
Not sure I understand you...  to edit a label/node like that, you set LabelEdit (property of treeview) to true...  select the node you want to edit, then click on it once.

... if you want to start the label edit through code:

   Function EditSelectedNode() As Boolean
        If TreeView1.SelectedNode Is Nothing Then
            Return False
        Else
            TreeView1.SelectedNode.BeginEdit()
            Return True
        End If
    End Function

NOTE:  Make sure the TreeView's LabelEdit property is set to true before you try to use the above
Thanks, one last question:

Is it possible to copy one treeview to another?

Thanks

Sven
Not really... you can't add an existing node into another treeview control (if you try it, you'll get an error).

I think you'd have to go through all the nodes making clones (or copies with the same properties so you're not actually using that node) of them.

I could be wrong tho.