Treeview: Set Style in code behind on certain conditons
How to set style of one node from code behind on certain conditions .
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend3days leftRegister
narasimman g146 reputationPosted Nov 3, 2011, 8:36 PM EDT
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);
}
}
narasimman g146 reputationPosted Nov 3, 2011, 8:38 PM EDT