bugDotGNU Portable.NET - Bugs: bug #11434, TreeNode Onwer Not Set via...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #11434: TreeNode Onwer Not Set via TreeNodesCollection.AddRange

Submitter:  None
Submitted:  Wed 29 Dec 2004 12:34:28 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed

Fri 18 Feb 2005 07:46:42 AM UTC, comment #1: 

fixed in cvs

Deryk Robosson <drobosson>
Group Member
Wed 29 Dec 2004 12:34:28 PM UTC, original submission:  

class System.Windows.Forms.TreeNodeCollection;
within pnetlib 0.6.8

Reproduction program source:
//------------- Form1.cs
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace WindowsApplication1
{

public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TreeView treeView1;

private System.ComponentModel.Container components = null;

public Form1()
{
InitializeComponent();
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

private void InitializeComponent()
{
this.treeView1 = new System.Windows.Forms.TreeView();
this.SuspendLayout();
//
// treeView1
//
this.treeView1.ImageIndex = -1;
this.treeView1.Location = new System.Drawing.Point(8, 8);
this.treeView1.Name = "treeView1";
this.treeView1.Nodes.AddRange(
new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("top 1",
new System.Windows.Forms.TreeNode[]{new System.Windows.Forms.TreeNode("Node 1")}),
new System.Windows.Forms.TreeNode("top 2")});
this.treeView1.SelectedImageIndex = -1;
this.treeView1.Size = new System.Drawing.Size(272, 208);
this.treeView1.TabIndex = 6;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 269);
this.Controls.Add(this.treeView1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);

}

[STAThread]
static void Main()
{
Application.Run(new Form1());
}
}
}
------------------------------------
When toggle node "top1", you would get exception about null reference.

Solution,(sorry i don't know how to do patch now)
replace void TreeNodeCollection.Add (TreeNodeCollection.cs:108)
by
  public virtual int Add(TreeNode node)
  {
    if (node.treeView != null && node.treeView.Sorted)
    {
       return owner.AddSorted(node);
    }
    else
    {
       owner.SizeChildrenArray();
       set_node_owner(node);
       node.parent = owner;
       int pos = owner.childCount++;
       node.index = pos;
       owner.children[node.index] = node;
       // Redraw if required.
       if (node.treeView != null && node.treeView.IsHandleCreated)
       {
          node.treeView.Draw(owner);
       }
       return pos;
    }
  }
  private void set_node_owner(TreeNode node)
  {
     node.treeView = owner.TreeView;
     foreach(TreeNode cn in node.Nodes)
       set_node_owner(cn);
  }


Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

 

Follow 2 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2005-02-18 drobosson StatusNone Fixed
    Open/ClosedOpen Closed

Back to the top

Powered by Savane 3.15-94dd.
Corresponding source code