dotgnu-pnet
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pnet-developers] [bugs #11434] TreeNode Onwer Not Set via TreeNodesColl


From: anonymous
Subject: [Pnet-developers] [bugs #11434] TreeNode Onwer Not Set via TreeNodesCollection.AddRange
Date: Wed, 29 Dec 2004 12:34:23 +0000 (UTC)
User-agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322; .NET CLR 2.0.40607)

This mail is an automated notification from the bugs tracker
 of the project: DotGNU Portable.NET.




/**************************************************************************/
[bugs #11434] Full Item Snapshot:

URL: <http://savannah.gnu.org/bugs/?func=detailitem&item_id=11434>
Project: DotGNU Portable.NET
Submitted by: 0
On: Wed 12/29/04 at 07:34

Category:  None
Severity:  5 - Average
Item Group:  None
Resolution:  None
Privacy:  Public
Assigned to:  None
Status:  Open


Summary:  TreeNode Onwer Not Set via TreeNodesCollection.AddRange

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);
  }













For detailed info, follow this link:
<http://savannah.gnu.org/bugs/?func=detailitem&item_id=11434>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]