TreeList.NodeCellStyle Event
Enables appearances to be assigned to individual cells.
Namespace: DevExpress.XtraTreeList
Assembly: DevExpress.XtraTreeList.v18.1.dll
Declaration
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 is raised for individual cells before they need to be repainted. The processed cell is identified by the event parameter’s NodeEventArgs.Node and CellEventArgs.Column properties. To customize the appearance settings used to paint the cell use the GetCustomNodeCellStyleEventArgs.Appearance property.
If more complex cell painting needs to be performed, handle the TreeList.CustomDrawNodeCell event.
For more information on appearances, see the Appearances document.
Note
The control’s events designed to change the appearance or rendering of control elements must not be used to update cell values or to modify the control’s layout. Any inappropriate operation which causes a layout update, may break the normal control behavior.
Example
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.
The image below shows the result.
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.Font = new Font(e.Appearance.Font, FontStyle.Bold);
}
}
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the NodeCellStyle event.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.