如何更改具体TreeListNode的字体?

时间:2011-04-07 12:34:26

标签: c# winforms devexpress xtratreelist

我需要更改XtraTreeList

中TreeListNode项的字体

对于标准TreeView节点,有Font属性。

2 个答案:

答案 0 :(得分:6)

查看DevExpress文档

XtraTreeList NodeCellStyle Event

How to: Customize the appearance of individual cells

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

答案 1 :(得分:-1)

或者您可以使用事件TreeList.CustomDrawNodeCell。