amarsha4
amarsha4

Reputation: 481

Change font colour of DevComponents AdvTree node

I'm looking to change the font colour of specific nodes on a DevComponent AdvTree. I found the following information, relating to changing style, on the DevComponents 'Knowledge Base':

// 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);

I can't understand what object is being referred in eStyleAlignment.Far.

Does anyone have experience with changing styles within the DevComponents DotNetBar?

Thanks,

Andy

Upvotes: 1

Views: 2179

Answers (1)

amarsha4
amarsha4

Reputation: 481

I figured out how to do this. The AdvTree control has a Styles property. This is a collection; styles can be added to it at design time.

Then the code to change the style of a particular node is:

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

Thanks,

Andy

Upvotes: 1

Related Questions