Skip to main content

Implement Alpha Blending via Custom Painting

Implement Alpha Blending via Custom Painting

You can implement alpha-blending using custom draw events. In this approach, you need to handle specific custom draw events to paint the Tree List’s elements using transparent brushes. This method is the most powerful one, since you can apply transparency to only one part of an element, or use gradient brushes.

The following sample code handles the TreeList.CustomDrawFooter event to paint the summary footer using a linear gradient brush. The starting and ending colors of this brush are transparent.

using System.Drawing.Drawing2D;
using DevExpress.XtraTreeList;
// ...

private void treeList1_CustomDrawFooter(object sender, CustomDrawEventArgs e) {
   LinearGradientBrush footerBrush = new LinearGradientBrush(e.Bounds, 
      Color.FromArgb(170, Color.Orange), Color.FromArgb(170, Color.DarkGreen), 
      LinearGradientMode.Vertical);

   using(footerBrush) {
      e.Cache.FillRectangle(footerBrush, e.Bounds);
   }

   e.Handled = true;
}

The image below shows the result.

AlphaBlending - CustomDrawFooter

See Also