I have a TreeView with check boxes, and when a user checks a child node, I want to go up the tree and check each parent. However, for some reason my application blows up whenever I touch the parent node. For the nodes in my tree, I've extended TreeNode to create my own objects with some data that I need to store in them, but I still reference them as TreeNodes when checking/unchecking. My code looks like this:
//checkBox checked event handler
if (node.Parent != null)
{
checkAllParents(node.Parent);
}
//
private void checkAllParents(TreeNode node)
{
node.Checked = true;
if (node.Parent != null)
{
checkAllParents(node.Parent);
}
}