Back to Devexpress

GroupCaptionCustomDrawEventArgs Class

windowsforms-devexpress-dot-xtraeditors-0635699f.md

latest4.9 KB
Original Source

GroupCaptionCustomDrawEventArgs Class

Supplies data for the GroupControl.CustomDrawCaption event.

Namespace : DevExpress.XtraEditors

Assembly : DevExpress.Utils.v25.2.dll

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

Declaration

csharp
public class GroupCaptionCustomDrawEventArgs :
    ObjectCustomDrawEventArgs
vb
Public Class GroupCaptionCustomDrawEventArgs
    Inherits ObjectCustomDrawEventArgs

GroupCaptionCustomDrawEventArgs is the data class for the following events:

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.

csharp
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;
}
vb
Imports System.Drawing.Drawing2D
Imports DevExpress.XtraEditors
' ...

Private Sub GroupControl1_CustomDrawCaption(ByVal sender As Object, _
ByVal e As GroupCaptionCustomDrawEventArgs) _
Handles GroupControl1.CustomDrawCaption
   Dim outerBrush As LinearGradientBrush = New LinearGradientBrush(e.CaptionBounds, _
     Color.LightBlue, Color.Blue, LinearGradientMode.Vertical)
   e.Cache.FillRectangle(outerBrush, e.CaptionBounds)
   outerBrush.Dispose()

   Dim innerRect As Rectangle = Rectangle.Inflate(e.CaptionBounds, -3, -3)
   Dim innerBrush As LinearGradientBrush = New LinearGradientBrush(innerRect, _
     Color.Blue, Color.LightBlue, LinearGradientMode.Vertical)
   e.Cache.FillRectangle(innerBrush, e.CaptionBounds)
   innerBrush.Dispose()

   Dim textRect As New RectangleF(innerRect.Left, innerRect.Top, _
     innerRect.Width, innerRect.Height)
   Dim outStrFormat As StringFormat = 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), textRect, outStrFormat)

   e.Handled = True
End Sub

Inheritance

Object EventArgs DevExpress.XtraEditors.ObjectCustomDrawEventArgsBase ObjectCustomDrawEventArgs GroupCaptionCustomDrawEventArgs

See Also

GroupCaptionCustomDrawEventArgs Members

CustomDrawCaption

DevExpress.XtraEditors Namespace