Treeview: Set Style in code behind on certain conditons
How to set style of one node from code behind on certain conditions .
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
narasimman gPosted Nov 4, 2011, 12:38 AM
narasimman gPosted Nov 4, 2011, 12:36 AM
private void PrintRecursive(TreeNode treeNode)
{
try
{
// Print each node recursively.
foreach (TreeNode tn in treeNode.Nodes)
{
if (//Condition to find your node)
{
//Change style
}
PrintRecursive(tn);
}
}
catch(Exception ex)
{
throw ex;
}
}
// Call the procedure using the TreeView.
private void CallRecursive(TreeView treeView)
{
TreeNodeCollection nodes = treeView.Nodes;
foreach (TreeNode n in nodes)
{
PrintRecursive(n);
}
}