.NET C# - How to check if all leaves are in WinForms TreeView.

You could easily make this into an extension methods like this.

public static class ExtensionMethods
{
    public static bool AllLeavesChecked(this TreeNode treeNode)
    {
        if (treeNode.Nodes.Count == 0)
        {
            return treeNode.Checked;
        }
        else
        {
            bool returns = true;
            foreach (TreeNode node in treeNode.Nodes)
            {
                returns &= node.AllLeavesChecked();
            }

            return returns;
        }
    }
}