If this is forms, you can for example iterate through each root node and call a recursive method to check that node and it's children. For example:
Iteration:
foreach (TreeNode node in treeView1.Nodes) {
CheckItems(node);
}
Recursive method:
private void CheckItems(TreeNode node) {
node.Checked = true;
foreach (TreeNode childNode in node.Nodes) {
childNode.Checked = true;
CheckItems(childNode);
}
}