https://bugzilla.novell.com/show_bug.cgi?id=363353
Summary: VS Designer generated TreeView code causes Mono
exception
Product: Mono: Class Libraries
Version: 1.2.6
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: Normal
Priority: P5 - None
Component: Windows.Forms
AssignedTo: [email protected]
ReportedBy: [EMAIL PROTECTED]
QAContact: [email protected]
CC: [EMAIL PROTECTED]
Found By: ---
VS Designer assigns TreeNodes to TreeView.Nodes before assigning the image list
to StateImageList for the TreeView. This causes Mono to throw an exception:
Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object
at System.Windows.Forms.TreeNode.get_StateImage () [0x00000]
at System.Windows.Forms.TreeNode.GetX () [0x00000]
at System.Windows.Forms.TreeNode.get_Bounds () [0x00000]
at (wrapper remoting-invoke-with-check)
System.Windows.Forms.TreeNode:get_Bounds ()
at System.Windows.Forms.TreeView.UpdateNode (System.Windows.Forms.TreeNode
node) [0x00000]
at (wrapper remoting-invoke-with-check)
System.Windows.Forms.TreeView:UpdateNode (System.Windows.Forms.TreeNode)
at System.Windows.Forms.TreeNodeCollection.SetupNode
(System.Windows.Forms.TreeNode node) [0x00000]
at System.Windows.Forms.TreeNodeCollection.Add (System.Windows.Forms.TreeNode
node) [0x00000]
at System.Windows.Forms.TreeNodeCollection.AddRange
(System.Windows.Forms.TreeNode[] nodes) [0x00000]
at TreeViewTest.Form1.InitializeComponent () [0x00000]
at TreeViewTest.Form1..ctor () [0x00000]
You can fix this by manually moving the StateImageList assignment to above the
lines that AddRange the TreeNodes to TreeViewNodes:
Example before:
treeNode4.StateImageIndex = 0;
treeNode4.Text = "Node2";
this.treeView1.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
treeNode1,
treeNode3,
treeNode4});
this.treeView1.SelectedImageIndex = 0;
this.treeView1.Size = new System.Drawing.Size(248, 222);
this.treeView1.StateImageList = this.imageList2;
this.treeView1.TabIndex = 0;
Example after:
treeNode4.StateImageIndex = 0;
treeNode4.Text = "Node2";
this.treeView1.StateImageList = this.imageList2;
this.treeView1.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
treeNode1,
treeNode3,
treeNode4});
this.treeView1.SelectedImageIndex = 0;
this.treeView1.Size = new System.Drawing.Size(248, 222);
this.treeView1.TabIndex = 0;
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
_______________________________________________
mono-bugs maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-bugs