开发者

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;
            }
        }
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜