A newer version of this page is available. Switch to the current version.

TreeList.NodeCellStyle Event

Allows you to customize the appearance of individual cells.

Namespace: DevExpress.XtraTreeList

Assembly: DevExpress.XtraTreeList.v19.2.dll

Declaration

[DXCategory("Appearance")]
public event GetCustomNodeCellStyleEventHandler NodeCellStyle

Event Data

The NodeCellStyle event's data class is GetCustomNodeCellStyleEventArgs. The following properties provide information specific to this event:

Property Description
Appearance Gets the appearance settings used to paint the cell currently being processed.
Column Gets a column to which the cell processed by an event belongs. Inherited from CellEventArgs.
Node Gets the current Tree List node. Inherited from NodeEventArgs.

Remarks

The NodeCellStyle event raises when a cell is about to be displayed. You can identify the cell by NodeEventArgs.Node and CellEventArgs.Column event arguments. To customize the appearance settings, use the GetCustomNodeCellStyleEventArgs.Appearance property. For more information on appearances, see the Appearances document.

IMPORTANT

Never change cell values or modify the control's layout on this event, or any other event designed to tune the control's appearance. Any action that causes a layout update can cause the control to malfunction.

If you need to completely redraw a cell, handle the TreeList.CustomDrawNodeCell event.

Examples

The following sample code handles the TreeList.NodeCellStyle event to modify the appearance of the "Budget" column's cells whose values are greater than 500,000.

Styles - GetCustomNodeCellStyle

using DevExpress.XtraTreeList;

private void treeList1_NodeCellStyle(object sender, GetCustomNodeCellStyleEventArgs e) {
   // Modify the appearance settings used to paint the "Budget" column's cells
   // whose values are greater than 500,000.
   if (e.Column.FieldName != "Budget") return;
   if (Convert.ToInt32(e.Node.GetValue(e.Column.AbsoluteIndex)) > 500000) {
      e.Appearance.BackColor = Color.FromArgb(80, 255, 0, 255);
      e.Appearance.ForeColor = Color.White;
      e.Appearance.FontStyleDelta = FontStyle.Bold;
   }
}
See Also