treeview| Control
Recently made a small software, a file browser, compared to Windows Explorer, you can view the contents of the file, rather than external programs open, support a variety of file formats, and later prepare to join the content-based search (intended to use the open source of the Dotlucene component). It needs to serialize the tree control, look up a lot of information, in CodeProject find a vb.net write, find a code converter into C #, modified a bit, changed to binary serialization. Attached below for the necessary reference.
Using System;
Using System.IO;
Using System.Windows.Forms;
Using System.Runtime.Serialization.Formatters.Binary;
Namespace Testall
{
<summary>
TreeView Serialization Class
</summary>
public class Treeviewdataaccess
{
Public treeviewdataaccess () {}
<summary>
Treeviewdata
</summary>
[Serializable ()]
public struct Treeviewdata
{
Public treenodedata[] Nodes;
<summary>
Recursive initialization of TreeView data
</summary>
<param name= "TreeView" ></param>
Public Treeviewdata (TreeView TreeView)
{
Nodes = new Treenodedata[treeview. Nodes.count];
if (TreeView). Nodes.count = 0)
{
Return
}
for (int i = 0; I <= TreeView. nodes.count-1; i++)
{
Nodes[i] = new Treenodedata (treeview. Nodes[i]);
}
}
<summary>
Pop the TreeView through Treeviewdata
</summary>
<param name= "TreeView" ></param>
public void Populatetree (TreeView treeview)
{
if (this. Nodes = = NULL | | This. nodes.length = 0)
{
Return
}
Treeview. BeginUpdate ();
for (int i = 0; I <= this. Nodes.length-1; i++)
{
Treeview. Nodes.Add (this. Nodes[i]. Totreenode ());
}
Treeview. EndUpdate ();
}
}
<summary>
Treenodedata
</summary>
[Serializable ()]
public struct Treenodedata
{
public string Text;
public int imageindex;
public int selectedimageindex;
public bool Checked;
public bool Expanded;
public object Tag;
Public treenodedata[] Nodes;
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.