Back to Devexpress

CustomDrawSeparatorEventArgs.SeparatorString Property

windowsforms-devexpress-dot-xtraverticalgrid-dot-events-dot-customdrawseparatoreventargs-7d85c8d8.md

latest5.6 KB
Original Source

CustomDrawSeparatorEventArgs.SeparatorString Property

Gets or sets the painted cell separator’s text.

Namespace : DevExpress.XtraVerticalGrid.Events

Assembly : DevExpress.XtraVerticalGrid.v25.2.dll

NuGet Packages : DevExpress.Win.Navigation, DevExpress.Win.VerticalGrid

Declaration

csharp
public string SeparatorString { get; set; }
vb
Public Property SeparatorString As String

Property Value

TypeDescription
String

A String value representing the painted cell separator’s text.

|

Remarks

Initially, the SeparatorString property contains the separator’s default text specified by the row’s MultiEditorRow.SeparatorString property. This property can be used in two ways:

  • reading the property’s value to paint the default text;
  • change the SeparatorString property value and leave the CustomDrawEventArgs.Handled property set to false. This forces the control to paint the cell separator in the default manner but with modified text.

Note : assigning values to the SeparatorString property has no effect if the row’s MultiEditorRow.SeparatorKind property is set to the SeparatorKind.VertLine value.

Example

The following sample code handles the VGridControlBase.CustomDrawSeparator event to custom paint cell separators. The image below shows the result.

csharp
using System.Drawing.Drawing2D;
using DevExpress.XtraVerticalGrid.Events;

// ...
private void vGridControl1_CustomDrawSeparator(object sender, CustomDrawSeparatorEventArgs e) {
   switch(e.SeparatorIndex) {
        case 0:
            // Fills the background.
            using(var backBrush = new LinearGradientBrush(e.Bounds, Color.Yellow, Color.Orange,
                    LinearGradientMode.Vertical))
                e.Cache.FillRectangle(backBrush, e.Bounds);

            ControlPaint.DrawBorder3D(e.Graphics, e.Bounds);
            e.SeparatorString = ",";
            // Paints the text which is displayed within the separator.
            e.Cache.DrawString(e.SeparatorString, e.Appearance.Font,
                Brushes.DarkBlue, e.Bounds, e.Appearance.GetStringFormat());
            break;
        case 1:
            using(var backBrush = new LinearGradientBrush(e.Bounds, Color.Orange, Color.Yellow,
                LinearGradientMode.Vertical))
                e.Cache.FillRectangle(backBrush, e.Bounds);
            ControlPaint.DrawBorder3D(e.Graphics, e.Bounds);
            e.SeparatorString = "/";
            e.Cache.DrawString(e.SeparatorString, e.Appearance.Font,
                Brushes.DarkBlue, e.Bounds, e.Appearance.GetStringFormat());
            break;
        default:
            break;
    }

    e.Handled = true;
}
vb
Imports System.Drawing.Drawing2D
Imports DevExpress.XtraVerticalGrid.Events

Private Sub VGridControl1_CustomDrawSeparator(ByVal sender As Object, _
ByVal e As CustomDrawSeparatorEventArgs) Handles VGridControl1.CustomDrawSeparator
    Select Case e.SeparatorIndex
        Case 0
            ' Fills the background.
            Using backBrush = New LinearGradientBrush(e.Bounds, Color.Yellow, Color.Orange, LinearGradientMode.Vertical)
                e.Cache.FillRectangle(backBrush, e.Bounds)
            End Using

            ControlPaint.DrawBorder3D(e.Graphics, e.Bounds)
            e.SeparatorString = ","
            ' Paints the text which is displayed within the separator.
            e.Cache.DrawString(e.SeparatorString, e.Appearance.Font, Brushes.DarkBlue, e.Bounds, e.Appearance.GetStringFormat())
        Case 1
            Using backBrush = New LinearGradientBrush(e.Bounds, Color.Orange, Color.Yellow, LinearGradientMode.Vertical)
                e.Cache.FillRectangle(backBrush, e.Bounds)
            End Using
            ControlPaint.DrawBorder3D(e.Graphics, e.Bounds)
            e.SeparatorString = "/"
            e.Cache.DrawString(e.SeparatorString, e.Appearance.Font, Brushes.DarkBlue, e.Bounds, e.Appearance.GetStringFormat())
        Case Else
    End Select

    e.Handled = True
End Sub

See Also

SeparatorString

SeparatorKind

CustomDrawSeparatorEventArgs Class

CustomDrawSeparatorEventArgs Members

DevExpress.XtraVerticalGrid.Events Namespace