I have a class called "Accessories" which Inherits "Surface", which inherits from the TreeNode class
A new instance of Surface class adds a class called "Region" as one of its nodes. It does this in the constructor, shown here:
The Accessories class does not add any nodes in its constructor. When a new one is created, it should have no child nodes:
Yet when my program is run, the initial accessories node has a region for a child node. When I step through the code of the Accessories constructor, the watch window tells me it already has a child node. Just to be sure, I commented out the Nodes.Add(new Region()) line of the Surface constructor, and sure enough the accessories node had no child nodes, therefore the Surface constructor is firing before the Accessories consuctor. Which is odd.
Why is this happening, and is there any way to stop it?
A new instance of Surface class adds a class called "Region" as one of its nodes. It does this in the constructor, shown here:
Code:
public Surface()
{
Nodes.Add(new Region());
}
The Accessories class does not add any nodes in its constructor. When a new one is created, it should have no child nodes:
Code:
public Accessories()
{
this.Text = "Accessories";
}
Yet when my program is run, the initial accessories node has a region for a child node. When I step through the code of the Accessories constructor, the watch window tells me it already has a child node. Just to be sure, I commented out the Nodes.Add(new Region()) line of the Surface constructor, and sure enough the accessories node had no child nodes, therefore the Surface constructor is firing before the Accessories consuctor. Which is odd.
Why is this happening, and is there any way to stop it?