我正在寻找更改DevComponent AdvTree上特定节点的字体颜色。我在DevComponents'知识库'上找到了与更改样式有关的以下信息:
// Create new style
ElementStyle styleRightAligned = new ElementStyle();
// Set text alignment to right
styleRightAligned.TextAlignment = eStyleTextAlignment.Far;
advTree1.Styles.Add(styleRightAligned);
// Add new cell to the AdvTree
Cell cell = new Cell();
cell.Text = "Right";
cell.StyleNormal = styleRightAligned;
// Assign style to cell, same style can be assigned to any number of cells
node1.Cells.Add(cell);
我无法理解eStyleAlignment.Far中引用的对象。
有没有人有在DevComponents DotNetBar中更改样式的经验?
谢谢,
安迪
答案 0 :(得分:1)
我想出了如何做到这一点。 AdvTree控件具有Styles属性。这是一个集合;样式可以在设计时添加到它。
然后,用于更改特定节点样式的代码为:
void ChangeNodeStyle(AdvTree tree, int node, int style)
{
tree.Nodes[node].Style = tree.Styles[style];
}
谢谢,
安迪