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

CustomDrawSeparatorEventArgs.SeparatorIndex Property

Gets the painted cell separator’s index.

Namespace: DevExpress.XtraVerticalGrid.Events

Assembly: DevExpress.XtraVerticalGrid.v24.2.dll

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

#Declaration

public int SeparatorIndex { get; }

#Property Value

Type Description
Int32

A zero-based integer representing the painted cell separator’s index.

#Remarks

When a multi-editor row consists of more than one item, row header cells as well as value cells are displayed one after another divided by cell separators. The SeparatorIndex property allows you to identify the painted cell separator. This can be useful for instance, when you need to paint different cell separators differently, as shown in the example below.

#Example

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

SeparatorIndex property

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;
}
See Also