how to show node buttons in treelist in devexpress c# code example
Example: how to show node buttons in treelist in devexpress c#
using System.Drawing;
using System.Drawing.Drawing2D;
using DevExpress.XtraTreeList;
private void treeList1_CustomDrawNodeButton(object sender, CustomDrawNodeButtonEventArgs e) {
Rectangle rect = Rectangle.Inflate(e.Bounds, 0, -2);
Brush backBrush = e.Cache.GetGradientBrush(rect, Color.Blue, Color.LightSkyBlue,
LinearGradientMode.ForwardDiagonal);
e.Cache.FillRectangle(backBrush, rect);
e.Cache.DrawRectangle(e.Cache.GetPen(Color.LightGray), rect);
string displayCharacter = e.Expanded ? "-" : "+";
StringFormat outCharacterFormat = e.Appearance.GetStringFormat();
outCharacterFormat.Alignment = StringAlignment.Center;
outCharacterFormat.LineAlignment = StringAlignment.Center;
e.Appearance.FontSizeDelta = -2;
e.Appearance.FontStyleDelta = FontStyle.Bold;
e.Cache.DrawString(displayCharacter, e.Appearance.Font,
e.Cache.GetSolidBrush(Color.White), rect, outCharacterFormat);
e.Handled = true;
}