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 );
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.