windowsforms-devexpress-dot-xtraverticalgrid-dot-vgridcontrolbase-f3190d28.md
Allows you to paint the control’s caption.
Namespace : DevExpress.XtraVerticalGrid
Assembly : DevExpress.XtraVerticalGrid.v25.2.dll
NuGet Packages : DevExpress.Win.Navigation, DevExpress.Win.VerticalGrid
[DXCategory("Appearance")]
public event CustomDrawCaptionEventHandler CustomDrawCaption
<DXCategory("Appearance")>
Public Event CustomDrawCaption As CustomDrawCaptionEventHandler
The CustomDrawCaption event's data class is DevExpress.XtraVerticalGrid.Events.CustomDrawCaptionEventArgs.
The following example handles the CustomDrawCaption event to paint the Vertical Grid’s caption.
using DevExpress.XtraVerticalGrid.Events;
private void vGridControl1_CustomDrawCaption(object sender, CustomDrawCaptionEventArgs e) {
LinearGradientBrush outerBrush = new LinearGradientBrush(e.Bounds, Color.LightBlue, Color.Blue, LinearGradientMode.Vertical);
using(outerBrush) {
e.Cache.FillRectangle(outerBrush, e.Bounds);
}
Rectangle innerRect = Rectangle.Inflate(e.Bounds, -3, -3);
LinearGradientBrush innerBrush = new LinearGradientBrush(innerRect, Color.Blue, Color.LightBlue, LinearGradientMode.Vertical);
using(innerBrush) {
e.Cache.FillRectangle(innerBrush, e.Bounds);
}
StringFormat outStrFormat = new StringFormat();
outStrFormat.Alignment = StringAlignment.Center;
outStrFormat.LineAlignment = StringAlignment.Center;
e.Cache.DrawString(e.DisplayText, e.Appearance.Font, e.Cache.GetSolidBrush(Color.White), innerRect, outStrFormat);
e.Handled = true;
}
Imports DevExpress.XtraVerticalGrid.Events
Private Sub vGridControl1_CustomDrawCaption(ByVal sender As Object, ByVal e As CustomDrawCaptionEventArgs)
Dim outerBrush As New LinearGradientBrush(e.Bounds, Color.LightBlue, Color.Blue, LinearGradientMode.Vertical)
Using outerBrush
e.Cache.FillRectangle(outerBrush, e.Bounds)
End Using
Dim innerRect As Rectangle = Rectangle.Inflate(e.Bounds, -3, -3)
Dim innerBrush As New LinearGradientBrush(innerRect, Color.Blue, Color.LightBlue, LinearGradientMode.Vertical)
Using innerBrush
e.Cache.FillRectangle(innerBrush, e.Bounds)
End Using
Dim outStrFormat As New StringFormat()
outStrFormat.Alignment = StringAlignment.Center
outStrFormat.LineAlignment = StringAlignment.Center
e.Cache.DrawString(e.DisplayText, e.Appearance.Font, e.Cache.GetSolidBrush(Color.White), innerRect, outStrFormat)
e.Handled = True
End Sub
See Also