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:

C#

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

VB

' Create new style
Dim styleRightAligned As New ElementStyle()
 
' Set text alignment to right

styleRightAligned.TextAlignment = eStyleTextAlignment.Far
 
advTree1.Styles.Add(styleRightAligned)
 
' Add new cell to the AdvTree

Dim cell As 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)

Related posts:

  1. How to display line number in DotNetBar for WinForms AdvTree Control left margin
  2. How to create custom columns when binding data to AdvTree
  3. How to enumerate through all nodes in AdvTree control
  4. How to accept external drag & drop on AdvTree control
  5. AdvTree Drag & Drop Events And Options