Solved

root node of the source treeView

Posted on 2009-05-11
7
234 Views
Last Modified: 2012-05-06
I am doing dragdrop operation from one tree to other for getting source node i am using
newNode = DirectCast(e.Data.GetData("System.Windows.Forms.TreeNode"), TreeNode)
but its only giving me node text and name

I also want to get root node of the source tree. how i can do this

Thanks
0
Comment
Question by:farjack1
  • 3
  • 3
7 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 24359659
To get the root node you could do something like:

        Dim rootNode As TreeNode = newNode
        While Not IsNothing(rootNode.Parent)
            rootNode = rootNode.Parent
        End While

0
 

Author Comment

by:farjack1
ID: 24359764
rootNode.Parent

this returning Nothing
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 24359774
One moment please...
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 24359877
It's working fine for me...I setup two TreeViews (TreeView1, TreeView2) on a Form and added some Nodes to TreeView1.

Here is some of my Debug output:

    Dropped Node: Node7
    Root Node: Node2
    FullPath: Node2\Node7

    Dropped Node: Node14
    Root Node: Node1
    FullPath: Node1\Node6\Node14

And here is the code:
Public Class Form1
 

    Private Sub TreeView1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TreeView1.MouseMove

        If e.Button = Windows.Forms.MouseButtons.Left Then

            Dim SourceNode As TreeNode = TreeView1.GetNodeAt(TreeView1.PointToClient(Cursor.Position))

            If Not IsNothing(SourceNode) Then

                TreeView1.DoDragDrop(SourceNode, DragDropEffects.All)

            End If

        End If

    End Sub
 

    Private Sub TreeView2_DragOver(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TreeView2.DragOver

        e.Effect = If(e.Data.GetDataPresent("System.Windows.Forms.TreeNode"), DragDropEffects.All, DragDropEffects.None)

    End Sub
 

    Private Sub TreeView2_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles TreeView2.DragDrop

        Dim DroppedNode As TreeNode = e.Data.GetData("System.Windows.Forms.TreeNode")

        Debug.Print("Dropped Node: " & DroppedNode.Text)
 

        Dim RootNode As TreeNode = DroppedNode

        While Not IsNothing(rootNode.Parent)

            rootNode = rootNode.Parent

        End While

        If Not (rootNode Is DroppedNode) Then

            Debug.Print("Root Node: " & rootNode.Text)

        End If
 

        Debug.Print("FullPath: " & DroppedNode.FullPath)

    End Sub
 

End Class

Open in new window

0
 

Expert Comment

by:praveenkumar_3i
ID: 24362164
Try to get Parent node of a xml documnet.

Code Sample:

                            XmlDocument xmldoc = new XmlDocument();
                            xmldoc.Load(strXMLFile);
                            XmlNode xmlRootNode = xmldoc.ParentNode;

0
 

Expert Comment

by:praveenkumar_3i
ID: 24362184
In Treeview

TreeNodeCollection nodes = tvwFolders.Nodes;
if (nodes.Count > 0)
{
// Select the root node
tvwFolders.SelectedNode = nodes[0];
}


0
 

Accepted Solution

by:
praveenkumar_3i earned 500 total points
ID: 24362191
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now