Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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