G
Guest
Hello,
I've posted the same question on msdn forums, but I'll try it here too since
I'm lost here.
I'm creating a custom TreeView with custom TreeNode classes nested.
This is a sample what I want to do:
MyTreeView class:
public partial class MyTreeView : TreeView
{
public MyTreeView()
{
InitializeComponent();
Nodes.Add(new MyTreeNode());
}
private class MyTreeNode : TreeNode
{
public MyTreeNode() :
base("MyNode")
{
}
}
}
When I drag this control to a windows form, It will show the correct node
inside (created in the constructor), but it will also create this line on
form's InitializeComponent() method:
WindowsApplication2.MyTreeView.MyTreeNode myTreeNode1 = new
System.Windows.Forms.TreeNode("MyNode");
The problem here is that 1) the nested type is private, 2) there is no cast
from TreeNode to MyTreeNode.
Since I don't need the nodes to show up at design time, there is any way to
not create them only when at design?
Or is there any other way to do this?
Thanks
Pedro
I've posted the same question on msdn forums, but I'll try it here too since
I'm lost here.
I'm creating a custom TreeView with custom TreeNode classes nested.
This is a sample what I want to do:
MyTreeView class:
public partial class MyTreeView : TreeView
{
public MyTreeView()
{
InitializeComponent();
Nodes.Add(new MyTreeNode());
}
private class MyTreeNode : TreeNode
{
public MyTreeNode() :
base("MyNode")
{
}
}
}
When I drag this control to a windows form, It will show the correct node
inside (created in the constructor), but it will also create this line on
form's InitializeComponent() method:
WindowsApplication2.MyTreeView.MyTreeNode myTreeNode1 = new
System.Windows.Forms.TreeNode("MyNode");
The problem here is that 1) the nested type is private, 2) there is no cast
from TreeNode to MyTreeNode.
Since I don't need the nodes to show up at design time, there is any way to
not create them only when at design?
Or is there any other way to do this?
Thanks
Pedro