UltraTree infragistics 如何更改 UltraTreeNode 的背景颜色?
UltraTree infragistics how to change the backcolor of UltraTreeNode?
我在 UltraTree 中有一个 textSearchEditor。当此编辑器中的文本匹配 UltraTreeNode.text 时,匹配节点的颜色将为黄色。我该怎么做?
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;
}
}
}
}
我按上面的方法试过了,但是没有任何反应...
要更改节点的背景颜色,您必须使用 Override
:
node.Override.NodeAppearance.BackColor = Color.Yellow;
我在 UltraTree 中有一个 textSearchEditor。当此编辑器中的文本匹配 UltraTreeNode.text 时,匹配节点的颜色将为黄色。我该怎么做?
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;
}
}
}
}
我按上面的方法试过了,但是没有任何反应...
要更改节点的背景颜色,您必须使用 Override
:
node.Override.NodeAppearance.BackColor = Color.Yellow;