2013-02-06 38 views
1

我正在尋找更改DevComponent AdvTree上特定節點的字體顏色。我發現下面的信息,與不斷變化的風格,在DevComponents「知識庫」:更改DevComponents AdvTree節點的字體顏色

// 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內的風格的經驗?

感謝,

安迪

回答

1

我想通了,如何做到這一點。 AdvTree控件具有Styles屬性。這是一個集合;樣式可以在設計時添加到它。

然後代碼更改特定節點的樣式是:

void ChangeNodeStyle(AdvTree tree, int node, int style) 
{ 
    tree.Nodes[node].Style = tree.Styles[style]; 
} 

謝謝,

安迪