Create an editable xml document (3) and perform the drag-and-drop operation.

Source: Internet
Author: User
Tags xpath
Perform the push operation
After defining the content displayed in the treeview, you should now be ready to handle how to move elements around. Most developers have to have a similar general idea when dealing with drag-and-drop operations, whether visual c ++ visual basic is used or.. net language, so I have been using the following four methods to handle this operation:
MouseDown ----- selected content
DragEnter --- the user starts to drag the selected project
DragOver --- drag the selected project to another project
DragDrop --- the user puts down the selected project somewhere
To execute these methods, you must give visual feedback on the operations that can and cannot be processed, and tell the user how they are executed, there are three direct problems that need to be considered because you do not have to worry about the detailed operations in the given context:
1. How do you match a node in the treeview control with a node in the underlying xml document?
2. How do users operate xml files to allow physical nodes to convert images?
3. How can you effectively execute large xml documents. If such a change has to be strengthened, you do not want to bind unnecessary things to the user interface.
Listing 1
A TreeNode's position maps to an XML node using an XPath query.

Private Sub XmlTreeView_MouseDown (ByVal sender As Object, ByVal e _
System. Windows. Forms. MouseEventArgs) Handles MyBase. MouseDown
'First check whether we 've clicked on a node in the tree view; if not,
'Just return
Dim pt As New Point (e. X, e. Y)
Drag_node = Me. GetNodeAt (pt)

If drag_node Is Nothing Then Return

'Highlight the node and build an xpath query so that we can remove it later
Xpath_remove_query = buildXPathQuery (drag_node)
Me. SelectedNode = drag_node

'Decide whether we're going to perform an intra-folder rearrangement (right
'Mouse button) or a genuine drag-and-drop (left mouse button );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.