void IEventSink.NotifyNodeChanged(DataNode node, int index) { NodeChanged?.Invoke(this, new TreeNodeEventArgs(node, index)); }
public TreeViewCustomStore() { DataNode root = new DataNode("Root", new DataNode [] { new DataNode("One", new DataNode [] { new DataNode("Elephant"), new DataNode("Tiger") }), new DataNode("Two", new DataNode [] { new DataNode("Monkey"), new DataNode("Lion") }), } ); DataNode root2 = new DataNode("Second Root", new DataNode [] { new DataNode("One", new DataNode [] { new DataNode("Elephant"), new DataNode("Tiger") }), new DataNode("Two", new DataNode [] { new DataNode("Monkey"), new DataNode("Lion") }), } ); MyTreeSource source = new MyTreeSource(); source.Add(root); source.Add(root2); source.Add(new InfiniteDataNode("Infinite")); TreeView tree = new TreeView(); var col = new ListViewColumn("Data"); col.Views.Add(new ImageCellView(source.ImageField)); col.Views.Add(new TextCellView(source.LabelField)); tree.Columns.Add(col); PackStart(tree, true); var hbox = new HBox(); var add = new Button("Add nodes"); var change = new Button("Change nodes"); var remove = new Button("Remove nodes"); hbox.PackStart(add); hbox.PackStart(change); hbox.PackStart(remove); PackStart(hbox); add.Clicked += delegate { var node = new DataNode("New child"); root.InsertChild(1, node); tree.SelectRow(node); }; remove.Clicked += delegate { if (root.Children.Count > 0) { root.RemoveChild(root.Children [root.Children.Count - 1]); } }; change.Clicked += delegate { var sel = (DataNode)tree.SelectedRow; if (sel != null) { sel.Name = "Modified"; } }; tree.DataSource = source; }
public void Add(DataNode node) { data.Add(node); node.EventSink = this; }