How to get all checked items but to exclude main nodes with subitems?
For example take a look in this picture:
I want to get all checked items but to exclude marekd with yellow but still to have their subitems listed.
So far i did this:
List<String> CheckedNames(System.Windows.Forms.TreeNodeCollection theNodes)
{
List<String> aResult = new List<String>();
if (theNodes != null)
{
foreach (System.Windows.Forms.TreeNode aNode in theNodes)
{
if (aNode.Checked)
{
string[] itemName = Regex.Split(aNode.Text, " - ");
aResult.Add(itemName[0]);
}
aResult.AddRange(CheckedNames(aNode.Nodes));
}
}
return aResult;
}