DevComponents.com

How to right-align the cell text in AdvTree control

If you want to right-align the text in AdvTree cell control you need to create new style and assign it to all cells that you want to have text right-aligned.

Note that using styles you can change many other appearance properties of the cell, like text color, background color etc.

Follow these steps to use code below:

1. Create new project
2. Add AdvTree control to the form
3. Right-click AdvTree control and choose Edit Columns... and create 2 new columns
4. Double clike form to create Form Load event handler
5. Add following code to the form:

// 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";
// Assign style to cell, same style can be assigned to any number of cells
cell.StyleNormal = styleRightAligned;
node1.Cells.Add(cell);

Would you like to...

Print this page Print this page

Email this page Email this page

Post a comment Post a comment

Subscribe me

Add to favoritesAdd to favorites

User Opinions (6 votes)

83% thumbs up 16% thumbs down

How would you rate this answer?

Helpful
Not helpful
Thank you for rating this answer.

Related Questions

No related questions were found.

Attachments

No attachments were found.