Assuming you are using Winforms, handle the BeforeCheck event for the TreeView:
private void myTreeView_BeforeCheck(object sender, TreeViewCancelEventArgs e)
{
if (e.Node.Parent != null && e.Node.Parent.Checked && e.Node.Checked)
{
e.Cancel = true;
}
}
This forbids unchecking nodes unless the immediate parent is also unchecked.
If this is not what you are trying to achieve, it is not clear from your question, so please explain what you are trying to achieve more clearly.