Skip to main content

GroupCaptionCustomDrawEventArgs Class

Supplies data for the GroupControl.CustomDrawCaption event.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.Utils.v24.1.dll

NuGet Packages: DevExpress.Utils, DevExpress.Wpf.Core

Declaration

public class GroupCaptionCustomDrawEventArgs :
    ObjectCustomDrawEventArgs

Remarks

The GroupControl.CustomDrawCaption event fires before the group’s caption is painted. It enables you to paint the group control caption manually. The GroupCaptionCustomDrawEventArgs class exposes properties that allow information about the group whose caption is being painted to be obtained.

Example

The following example demonstrates how to handle the GroupControl.CustomDrawCaption event to manually paint a group control’s caption.

The image below shows the result.

GroupControl_CustomDrawCaption

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

private void groupControl1_CustomDrawCaption(object sender, GroupCaptionCustomDrawEventArgs e) {
   LinearGradientBrush outerBrush = new LinearGradientBrush(e.CaptionBounds, 
     Color.LightBlue, Color.Blue, LinearGradientMode.Vertical);
   using(outerBrush) {
      e.Cache.FillRectangle(outerBrush, e.CaptionBounds);
   }

   Rectangle innerRect = Rectangle.Inflate(e.CaptionBounds, -3, -3);
   LinearGradientBrush innerBrush = new LinearGradientBrush(innerRect, Color.Blue, 
     Color.LightBlue, LinearGradientMode.Vertical);
   using(innerBrush) {
      e.Cache.FillRectangle(innerBrush, e.CaptionBounds);
   }

   StringFormat outStrFormat = new StringFormat();
   outStrFormat.Alignment = StringAlignment.Center;
   outStrFormat.LineAlignment = StringAlignment.Center;
   e.Cache.DrawString(e.Info.Caption, e.Info.AppearanceCaption.Font, 
     e.Cache.GetSolidBrush(Color.White), innerRect, outStrFormat);

   e.Handled = true;
}

Inheritance

Object
EventArgs
ObjectCustomDrawEventArgs
GroupCaptionCustomDrawEventArgs
See Also