TreeView for WinForms | ComponentOne
In This Topic
    Import Data
    In This Topic

    TreeView supports both exporting and importing data to and from an XML document.

    The C1TreeView class provides the ReadXml method that allows you to load the treeView with the data of the XML document. The method accepts the XML file path as the parameter to determine the file from which the data is to be loaded.

    In addition, the C1TreeView class provides the WriteXml method that enables you to save the treeview contents to an XML document. Just like the ReadXml method, this method also accepts the file path as the parameter to determine the file to which the contents of the treeview are to be saved.

    The following code snippet first imports data from an XML document (Doc.XML) to the TreeView control, and then exports data from the TreeView control to another XML document (TreeView.XML).

    ' call the ReadXml method
    C1TreeView1.ReadXml("C:/Users/GPCTAdmin/Desktop/Doc.XML")
    
    ' call the WriteXml method
    C1TreeView1.WriteXml("C:/Users/GPCTAdmin/Desktop/TreeView.XML")
    
    // call the ReadXml method
    c1TreeView1.ReadXml("C:/Users/GPCTAdmin/Desktop/Doc.XML");
    
    // call the WriteXml method
    c1TreeView1.WriteXml("C:/Users/GPCTAdmin/Desktop/TreeView.XML");
    
    Note: The latest WinForms .NET Edition does not include rich design-time support yet. We will enhance it in future releases.