I am using VS 2005 (.NET 2.0) C# working on a Winform with functionality of XML parsing to a TreeView.
I'm planning to enable the checkboxes of the treeview list. Actually, I already enabled them. I found this code here while looking for some properties of TreeView and TreeNode that might be of help. I found TreeNode.Checked Property and TreeView.CheckBoxes Property.
public void HighlightCheckedNodes()
{
int countIndex = 0;
string selectedNode = "Selected customer nodes are : ";
foreach (TreeNode myNode in myTreeView.Nodes[0].Nodes)
{
// Check whether the tree node is checked.
if(myNode.Checked)
{
// Set the node's backColor.
myNode.BackColor = Color.Yellow;
selectedNode += myNode.Text+" ";
countIndex++;
}
else
myNode.BackColor = Color.White;
}
if(countIndex > 0)
MessageBox.Show(selectedNode);
else
MessageBox.Show("No nodes are selected");
}
So I tried it on my test project and it only worked on the parent nodes, not on the child nodes. What I want to do and to happen is that I have to also determine the checked state of the childnodes. I'm working on a project that needs selection of single to multiple child nodes and executing an external program once after checked. Is this possible, with the childnodes? Or are there any other alternatives.
Let me know if I'm unclear on anything. Thank you in advance.
Aucun commentaire:
Enregistrer un commentaire