Note that there are some explanatory texts on larger screens.

plurals
  1. POTree View not showing update
    primarykey
    data
    text
    <p>I have a TreeView in my Windows Form user interface. I want to fill it up from a database, but it does not refresh ever, even though if I WriteLine() every node, it is in memory as I expect.</p> <p>In order to make it more easy to understand, I wrote a little example program that only has one button that creates a TreeView and a TreeView called treeView1 to display its content.</p> <p>If anyone can tell me where I have misunderstood the use of the TreeView, it would be a tremendous help.</p> <pre><code>private void button1_Click(object sender, EventArgs e) { // create a tree TreeView t = new TreeView(); TreeNode[] child = new TreeNode [1]; child[0]=new TreeNode("myCat"); child[0].Name = "IndependantOne"; TreeNode categoryNode = new TreeNode("catIdTag", child); categoryNode.Name = "Citizen Cat 5239002147"; t.Nodes.Add(categoryNode); // some stuff under the first node TreeNode[] mouseNode = new TreeNode[1]; mouseNode[0] = new TreeNode("myMouse"); mouseNode[0].Name = "SqueakyOne"; TreeNode[] childItem = new TreeNode[1]; childItem[0] = new TreeNode("mouseIdTag", mouseNode); childItem[0].Name = "Citizen Mouse 54655654649"; TreeNode eltNode = new TreeNode("Cheese", childItem); eltNode.Name = "Emmental"; t.Nodes["Citizen Cat 5239002147"].Nodes.Add(eltNode); // fill in the winform treeview if (t != null) { //treeView1.Visible = false; treeView1.BeginUpdate(); treeView1.Nodes.Clear(); treeView1.TopNode = t.TopNode; foreach (TreeNode n in t.Nodes) { treeView1.Nodes.Add(n); System.Diagnostics.Debug.WriteLine("Category Node contains: " + treeView1.Nodes[n.Name].Name + " at " + treeView1.Nodes[n.Name].Level); foreach (TreeNode no in treeView1.Nodes[n.Name].Nodes) { System.Diagnostics.Debug.WriteLine("Category Node Nodes contains: " + no.Name); } } /* This part I tried and it doesn't work either, still add it in the question if anyone knows if it's wiser? this.treeView1 = t; this.treeView1.Location = new System.Drawing.Point(233, 12); this.treeView1.Name = "treeView1"; this.treeView1.Size = new System.Drawing.Size(351, 277); this.treeView1.TabIndex = 11; this.treeView1.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView1_AfterSelect); */ treeView1.EndUpdate(); this.treeView1.Update(); this.treeView1.Refresh(); treeView1.Show(); //this.Refresh(); } } </code></pre> <p>I also tried setting the treeView1 with </p> <pre><code> treeView1 = t; </code></pre> <p>It was not a success...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload