下面的示例代码接管了 TreeList.NodeCellStyle 事件来修改“Budget”列中取值大于 500,000 的单元格的外观。

下面的插图展示了运行结果。

C#CopyCode image复制代码
using DevExpress.XtraTreeList;

private void treeList1_NodeCellStyle(object sender, GetCustomNodeCellStyleEventArgs e) {
   // Modifying 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);
   }
}
Visual BasicCopyCode image复制代码
Imports DevExpress.XtraTreeList

Private Sub TreeList1_NodeCellStyle(ByVal sender As Object, _
ByVal e As GetCustomNodeCellStyleEventArgs) Handles TreeList1.CustomNodeCellStyle
   ' Modifying the appearance settings used to paint the "Budget" column's cells
   ' whose values are greater than 500,000 .
   If e.Column.FieldValue <> "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.Font = New Font(e.Appearance.Font, FontStyle.Bold)
   End If
End Sub