If I handle a RadTreeNode in this way:
public
partial
class
RadForm2 : Telerik.WinControls.UI.RadForm
{
private
RadTreeNode m_myNode1;
private
RadTreeNode m_myNode2;
public
RadForm2()
{
InitializeComponent();
m_myNode1 =
new
RadTreeNode();
m_myNode2 =
new
RadTreeNode();
m_myNode1.Nodes.Add(m_myNode2);
radTreeView1.Nodes.Add(m_myNode1);
}
protected
override
void
OnLoad(EventArgs e)
{
base
.OnLoad(e);
var treeview1 = m_myNode1.TreeView;
if
(treeview1 ==
null
)
throw
new
InvalidOperationException();
//var x = m_myNode2.TreeViewElement; this solves the problem, by calling FindTreeView internally
var treeview2 = m_myNode2.TreeView;
if
(treeview2 ==
null
)
throw
new
InvalidOperationException();
}
}
The second Exception is thrown.
The workaround is in the comment, if you call m_myNode2.TreeViewElement or m_myNode2.Nodes before, everything works fine,
anything that causes internally a call to "TreeViewElement" or "FindTreeView" (i digged a bit in the source code).
So this happens only on Nodes, without Childnodes and not for Rootnodes.
It's more a Bug-Report than a Question, but don't know where to Post ist.
If the TreeView Property is the first Property called, on a RadTreeNode, it always has the value null.