how to highlight individual items in treeview in WF
I'm building an application with treeview in windows form. I would like to change the background color/highlight individual items in the treeview based on some criteria. Does anyone开发者_运维知识库 have any suggestions on how to accomplish this?
Thank you very much!
Jason
void HighlightNodes(TreeNodeCollection nodes)
{
if (nodes != null)
{
foreach (TreeNode node in nodes)
{
// Process sub-nodes
if (node.Nodes.Count > 0)
{
HighlightNodes(node.Nodes);
}
if (criteriaIsMet)
{
node.BackColor = SystemColors.Highlight;
}
else
{
node.BackColor = Color.Empty;
}
}
}
}
精彩评论