Juicern
Juicern

Reputation: 322

UltraTree infragistics how to change the backcolor of UltraTreeNode?

I have a textSearchEditor in UltraTree. When text in this Editor matches UltraTreeNode.text, the color of the matched node will be yellow. How can I do it?

private void _SearchRole()
{
    string strMatch = this.ultraTextEditorRoleSearch.Text.Trim().ToLower();
    if(strMatch == string.Empty)
    {
        //全部恢复原来的颜色
        foreach(var node in this.treeRole.Nodes)
        {
            if (node.Selected) node.Control.Appearance.BackColor = SystemColors.Highlight;
            else node.Control.Appearance.BackColor = SystemColors.GradientActiveCaption;
        }
    }
    else
    {
        foreach(var node in this.treeRole.Nodes)
        {
            if (node.Selected) node.Control.Appearance.BackColor = SystemColors.Highlight;
            else if(node.Text.Contains(strMatch))
            {
                node.Control.Appearance.BackColor = Color.Yellow;
            }
            else
            {
                node.Control.Appearance.BackColor = SystemColors.GradientActiveCaption;
            }
        }
    }            
}

I tried like above, but nothing happens...

Upvotes: 0

Views: 591

Answers (1)

M. Bauer
M. Bauer

Reputation: 199

To change the backcolor of a node you have to use Override:

node.Override.NodeAppearance.BackColor = Color.Yellow;

Upvotes: 1

Related Questions