Back to Devexpress

SpreadsheetControl.CustomDrawFrozenPaneBorder Event

windowsforms-devexpress-dot-xtraspreadsheet-dot-spreadsheetcontrol-b0d554db.md

latest6.1 KB
Original Source

SpreadsheetControl.CustomDrawFrozenPaneBorder Event

Enables frozen pane borders to be painted manually.

Namespace : DevExpress.XtraSpreadsheet

Assembly : DevExpress.XtraSpreadsheet.v25.2.dll

NuGet Package : DevExpress.Win.Spreadsheet

Declaration

csharp
public event CustomDrawFrozenPaneBorderEventHandler CustomDrawFrozenPaneBorder
vb
Public Event CustomDrawFrozenPaneBorder As CustomDrawFrozenPaneBorderEventHandler

Event Data

The CustomDrawFrozenPaneBorder event's data class is CustomDrawFrozenPaneBorderEventArgs. The following properties provide information specific to this event:

PropertyDescription
CacheGets an object that serves as the storage for pens, fonts and brushes. Inherited from CustomDrawObjectEventsArgs.
ForeColorGets the color of the frozen pane border line.
GraphicsGets an object used for painting. Inherited from CustomDrawObjectEventsArgs.
HandledGets or sets whether an event is handled. If true, the default actions are not required. Inherited from CustomDrawObjectEventsArgs.
Point1Gets the first endpoint of the frozen pane border line.
Point2Gets the second endpoint of the frozen pane border line.
TypeGets whether the frozen pane is vertical or horizontal.
WidthGets the width of the frozen pane border line.

The event data class exposes the following methods:

MethodDescription
DrawDefault()Renders the element using the default drawing mechanism. Inherited from CustomDrawObjectEventsArgs.

Remarks

The CustomDrawFrozenPaneBorder event is raised before a frozen pane border is painted. Event argument properties provide the objects and information required to paint the frozen pane border.

Set the CustomDrawObjectEventsArgs.Handled property to true to cancel default painting. Use the CustomDrawObjectEventsArgs.DrawDefault method to perform default painting within the event handler.

The following code paints borders of the vertical and horizontal frozen panes in different colors and line widths. The worksheet appears as shown in the image below.

csharp
using System.Drawing;
using System.Windows.Forms;
using DevExpress.XtraSpreadsheet;

// ...

       private void spreadsheetControl1_CustomDrawFrozenPaneBorder
       (object sender, CustomDrawFrozenPaneBorderEventArgs e)
       {
            e.Handled = true;

            // Vertical frozen pane border
            //(line color is pink, line width is 3)
            if (e.Type == FrozenPaneBorderType.Vertical)
                using (Pen pen = new Pen(Color.DeepPink, 3))
                {
                    e.Graphics.DrawLine(pen, e.Point1, e.Point2);
                }

            // Horizontal frozen pane border
            //(line color is violet, line width is default)
            else 
               e.Graphics.DrawLine(Pens.BlueViolet, e.Point1, e.Point2);
        }
vb
Imports Microsoft.VisualBasic
Imports System.Drawing
Imports System.Windows.Forms
Imports DevExpress.XtraSpreadsheet

' ...

    Private Sub spreadsheetControl1_CustomDrawFrozenPaneBorder(ByVal sender As Object, ByVal e As CustomDrawFrozenPaneBorderEventArgs)
        e.Handled = True

        ' Vertical frozen pane border
        '(line color is pink, line width is 3)
        If e.Type = FrozenPaneBorderType.Vertical Then
            Using pen As New Pen(Color.DeepPink, 3)
                e.Graphics.DrawLine(pen, e.Point1, e.Point2)
            End Using

        ' Horizontal frozen pane border
        '(line color is violet, line width is default)
        Else
            e.Graphics.DrawLine(Pens.BlueViolet, e.Point1, e.Point2)
        End If
    End Sub

See Also

FreezePanes

FreezeColumns

FreezeRows

SpreadsheetControl Class

SpreadsheetControl Members

DevExpress.XtraSpreadsheet Namespace