Create an editable XML document (for five) execution TreeView control

zhaozj2021-02-17  57

TreeView control in execution

For more perfect, the list 4 contains the final TreeVie controls of VB.NET Version, or C # Version. For more easy to use, I redefine the structure and code. At the same time, KeyDown control is added to support some default shortcuts such as: control-n, F2 (editing), and DEL (delete).

It seems that there is no need to add any events, so the final API contains a method and eight attributes, they are listed in Table 1, most of them are simple symbols, or the default switch, I am adding them to let you You can choose to use to enhance your editable feature

Table 1: The properties and methods of the XMLTreeView control, you can use them in your application

Attribute

Type

Parameter

Description

XMLDROPTARGET

Get

System.xml.xmlnode

THE XML Node Corresponding to The Currently Selected Node in The TreeView

ActiveXMLDocument

Get

System.xml.xmldocument

THE XML Document Bound to the TreeView. This Updates as the tree change

Xpathfilter

GET; SET

String

The XPath Filter Used to Identify The Element OR Attribute Whose Value Will Be Used to Display The Folder's Name. A Folder Constitutes The Tree View's Smallst Navigable Unit

XmlinsertionNode

GET; SET

System.xml.xmlnode

The Template for a New Folder. The TreeView Caches this, And Clones It when When A New Folder is Required.

Dragdropactive

GET; SET

Bool

Flag Denoting WHETHER A DRAG / DROP OPERATION IS CURRENTLY IN Progress.

EnableEditnode

GET; SET

Bool

Flag Denoting WHether Label Editing Is Supported (Default IS YES)

Enabledeletenode

GET; SET

Bool

Flag Denoting WHether Folder Deletion Is Supported (Default IS YES)

EnableInsertNode

GET; SET

Bool

Flag Denoting WHether Folder INSERTION IS Supported (Default Is Yes)

Method:

Returns

Parameter

Description

Load

Void

System.xml.xmldocument

Loads the specified XML Document and usees it to populate the treeView. Set xpathfilter prior to call load () to define an appropriate view on the underlying data.

Call this article with the Sample Project project, you can see the TreeView control in the execution, this simple project is a cut version in the directory administrator I mentioned earlier, and it is necessary to say that only four lines can be realized. A drag and drop operation, Figure 3 shows the user to create a new folder collection [C #]

// load the xml document from a file

XmlDocument = new system.xml.xmldataDocument ();

XmlDocument.Load (strXmldocument);

// after setting the path filter, loading the

// Document Into the TreeView

XMLTreeView1.xpathfilter = "Attribute :: ID";

XMLTreeView1.Load (XmLDocument);

// defining XMlinsertionNode Allows Creation of New

// Nodes forin the treeview

System.xml.xmldocument INSERT_FRAGMENT = New

System.xml.xmldocument ();

INSERT_FRAGMENT.LOADXML ("

");

XmltreeView1.xmlinsertionNode =

INSERT_FRAGMENT.DOCUMENTELEMENT;

[Vb]

'Loading the xml document from a file

XMLDocument = new system.xml.xmldataDocument ()

XMLDocument.Load (strXmldocument)

'After setting the path filter, loading the

'Document Into the TreeView

XmltreeView1.xpathfilter = "Attribute :: id"

XMLTreeView1.Load (XmLDocument)

'Defining XMlinsertionNode Allows Creation of New

'Nodes forin the treeview

DIM INSERT_FRAGMENT AS New System.xml.xmldocument ()

INSERT_FRAGMENT.LOADXML (" " & _

)

XmltreeView1.xmlinsertionNode =

INSERT_FRAGMENT.DOCUMENTELEMENT

Figure 2 shows a list of directories, Figure 3 shows a detailed final directory

Figure 2. The Catalog Administrator Form: this Figure shows the hierarchical tree details and the details for anly.

Figure 3. Final Catalog. The Figure final catalog. The other part of the code handles the editable product list, and updated XML documents. So when you turn off the application, the code saves all modifications to the document. I hope that these can have some good inspiration to your project, or enrich your components or interface development.

转载请注明原文地址:https://www.9cbs.com/read-30361.html

New Post(0)