private void btnCancel_Click(object sender, EventArgs e) { treeView1.Nodes.Clear(); insert_deleted.Changes.Clear(); try { root = DeSerializeTree(); //lấy cây đã lưu. } catch { fs.Close(); MessageBox.Show("this is a new tree.", "Caution", MessageBoxButtons.OK, MessageBoxIcon.Information); root = new DirectoryShell() { Name = "Directory\\Background" }; // tạo cây mới. } root.SetParentForChild(); // vì quá kém cõi nên phải set cha thủ công, ko thể tự động. cursor = (DirectoryShell)root; // đây là con trỏ hiện tại để tui test. insert_deleted = new InsertDeleteManager((DirectoryShell)root); view_root = new TreeNode() { Tag = root, Text = "Root" }; CreateViewRoot(); treeView1.Nodes.Add(view_root); }
public Form1() { InitializeComponent(); try { root = DeSerializeTree(); //lấy cây đã lưu. } catch { fs.Close(); MessageBox.Show("this is a new tree.", "Caution", MessageBoxButtons.OK, MessageBoxIcon.Information); root = new DirectoryShell() { Name = "Directory\\Background" }; // tạo cây mới. } root.SetParentForChild(); // vì quá kém cõi nên phải set cha thủ công, ko thể tự động insert_deleted = new InsertDeleteManager((DirectoryShell)root); view_root = new TreeNode() { Tag = root, Text = "Root" }; treeView1.Nodes.Add(view_root); treeView1.ImageList = new ImageList(); treeView1.ImageList.Images.Add(new Bitmap(1, 1)); btnCancel.Hide(); btnApplyofEdit.Hide(); CreateViewRoot(); }