如何在c#中序列化我的treeview控件

时间:2016-09-28 10:29:25

标签: c# .net winforms

namespace TreeViewControl
{
    [Serializable]
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

    private void button1_Click(object sender, EventArgs e)
    {
        string n = textBox1.Text;
        if (treeView1.SelectedNode == null)
        {
            treeView1.Nodes.Add(n, n);
        }
        else
        {
            treeView1.SelectedNode.Nodes.Add(n, n);
        }
    }
}
  }

//有人请帮助我,我想序列化这段代码

1 个答案:

答案 0 :(得分:-1)

我已经有了在这里序列化树发布的方法,它可能对某人有帮助......

string filename = Application.StartupPath +“\ Tree.dat”;         private void btnAddNodes_Click(object sender,EventArgs e)         {//树已在btn点击事件中创建

        Private Sub radgrdResources_UpdateCommand(sender As Object, e As GridCommandEventArgs) Handles radgrdResources.UpdateCommand
' This will be invoked when you clikc the button and fire off the Radgrid's native save.
    End Sub