windowsforms-devexpress-dot-xtratreelist-dot-treelist-8087283a.md
You must use the NodeCellStyle event instead
Provides the ability to assign custom style to individual cells.
Namespace : DevExpress.XtraTreeList
Assembly : DevExpress.XtraTreeList.v25.2.dll
NuGet Packages : DevExpress.Win.Navigation, DevExpress.Win.TreeList
[Browsable(false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("You must use the NodeCellStyle event instead")]
public event GetCustomNodeCellStyleEventHandler GetCustomNodeCellStyle
<Browsable(False)>
<EditorBrowsable(EditorBrowsableState.Never)>
<Obsolete("You must use the NodeCellStyle event instead")>
Public Event GetCustomNodeCellStyle As GetCustomNodeCellStyleEventHandler
The GetCustomNodeCellStyle 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. |
This event is obsolete. Use the TreeList.NodeCellStyle event instead.
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.
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;
}
}
Imports DevExpress.XtraTreeList
Sub TreeList1_NodeCellStyle(sender As Object, e As DevExpress.XtraTreeList.GetCustomNodeCellStyleEventArgs) Handles TreeList1.NodeCellStyle
' Modify the appearance settings used to paint the "Budget" column's cells
' whose values are greater than 500,000.
If e.Column.FieldName <> "Budget" Exit Sub
If Convert.ToInt32(e.Node.GetValue(BudgetColumnID)) > 500000 Then
e.Appearance.BackColor = Color.FromArgb(80, 255, 0, 255)
e.Appearance.ForeColor = Color.White
e.Appearance.FontStyleDelta = FontStyle.Bold
End If
End Sub
See Also