looping through some treelist checkbox nodes, and trying to set some child nodes to true. when I try set one, either true or false it causes an exception.
'childNode.Checked' threw an exception of type 'System.NullReferenceException'
Am i missing something obvious?
thanks
private void FluidFilterTree_AfterCheck(object sender, TreeViewEventArgs e)
{
TreeNode ActiveNode = e.Node;
TreeNode childNode = ActiveNode.FirstNode;
if (ActiveNode.Parent == null) // if null it is the parent, check all children
{
for (int x = 0; x < ActiveNode.GetNodeCount(false); x++) // loop through children nodes
{
childNode.Checked = false; //?
childNode = childNode.NextNode;
}
}
MessageBox.Show(e.Node.Text);
}
The object childNode is set and is working, I have a breakpoint on the line and it works until it tries to set .checked=true. So I'm not sure this is a duplicate of the standard "what does this exception mean" I understand the exception but not sure why it is relevant in this case as I know both childNode and true exist