when binding the tree to a collection like
child 2.1.1 -> 2.3.1 won't be visible
some sample code
Create a new project, add the following code and run.
Uncomment the row : // root.Children[0].Children.Add(new NodeItem("hide me and child 2.1.1 -> child 2.3.1 will be invisible"))
---- code:
using System;using System.Collections.ObjectModel;using System.ComponentModel;using System.Windows.Forms;using Infragistics.Win.UltraWinTree; namespace BindTreeTest{ public class Form1 : Form { /// <summary> /// Required designer variable. /// </summary> private readonly IContainer components = null; private UltraTree ultraTree1; public Form1() { this.InitializeComponent(); var root = new NodeItem("root"); root.Children.Add(new NodeItem("child 1")); root.Children.Add(new NodeItem("child 2")); // if this node is hidden, the child 2.1.1 -> 2.1.3 nodes will not be visible // root.Children[0].Children.Add(new NodeItem("hide me and child 2.1.1 -> child 2.1.3 will be invisible")); root.Children[1].Children.Add(new NodeItem("child 2.1")); root.Children[1].Children.Add(new NodeItem("child 2.2")); root.Children[1].Children.Add(new NodeItem("child 2.3")); root.Children[1].Children[0].Children.Add(new NodeItem("child 2.1.1")); root.Children[1].Children[1].Children.Add(new NodeItem("child 2.2.1")); root.Children[1].Children[2].Children.Add(new NodeItem("child 2.3.1")); var collection = new ObservableCollection<NodeItem> {root}; this.ultraTree1.DataSource = collection; this.ultraTree1.ExpandAll(); } /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (this.components != null)) { this.components.Dispose(); } base.Dispose(disposing); } private void ultraTree1_ColumnSetGenerated(object sender, ColumnSetGeneratedEventArgs e) { e.ColumnSet.NodeTextColumn = e.ColumnSet.Columns["Text"]; } /// <summary> /// The main entry point for the application. /// </summary> [STAThread] private static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { var _override1 = new Infragistics.Win.UltraWinTree.Override(); this.ultraTree1 = new Infragistics.Win.UltraWinTree.UltraTree(); ((System.ComponentModel.ISupportInitialize) (this.ultraTree1)).BeginInit(); this.SuspendLayout(); // // ultraTree1 // this.ultraTree1.Dock = System.Windows.Forms.DockStyle.Fill; this.ultraTree1.Location = new System.Drawing.Point(0, 0); this.ultraTree1.Name = "ultraTree1"; _override1.ShowExpansionIndicator = Infragistics.Win.UltraWinTree.ShowExpansionIndicator.CheckOnDisplay; this.ultraTree1.Override = _override1; this.ultraTree1.Size = new System.Drawing.Size(579, 432); this.ultraTree1.TabIndex = 0; this.ultraTree1.ViewStyle = Infragistics.Win.UltraWinTree.ViewStyle.Standard; this.ultraTree1.ColumnSetGenerated += new Infragistics.Win.UltraWinTree.ColumnSetGeneratedEventHandler(this.ultraTree1_ColumnSetGenerated); // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(579, 432); this.Controls.Add(this.ultraTree1); this.Name = "Form1"; this.Text = "Form1"; ((System.ComponentModel.ISupportInitialize) (this.ultraTree1)).EndInit(); this.ResumeLayout(false); } #endregion #region Nested type: NodeItem public class NodeItem : NodeItemBase { public NodeItem(string text) : base(text) { } } #endregion #region Nested type: NodeItemBase public abstract class NodeItemBase { protected NodeItemBase(string text) { this.Children = new ObservableCollection<NodeItemBase>(); this.Text = text; } public string Text { get; set; } public ObservableCollection<NodeItemBase> Children { get; private set; } } #endregion }}
Hi Mike,
The ObservableCollection class is now standard in .NET 4.0
I've uploaded a sample project, replaced the ObservableCollection to a BindingList and upgraded to the latest ServiceRelease. Still doesn't work.
Hi,
Perhaps I'm confused about the issue. I ran your sample and I can see the "child 2.1.3" node in the tree. It shows up just fine. Are you saying that on your machine, you cannot see it?
Do I have to do something with the sample to get the problem to occur. There's a note here about hiding the node under Child 1. What do you mean by "hide?" Do you mean collapse the child 1 node? I tried this and it works just fine.
Or actually set the node's Visible property to false? If so, where are you doing this? There's no code in the sample that refers to a node that I can see.