Skip to main content

Column panel borders + spacing between cell border and content

Comments

1 comment

  • Dapfor Team

    Dear Josh,

    You can use custom drawing to change appearance of column separator:

    grid.PaintColumnCaption += delegate(object sender, PaintColumnCaptionEventArgs e)
    {
        e.PaintAll();
        e.Handled = true;

        //Draw vertical lines in the beginning and the end of the column
        e.Graphics.DrawLine(Pens.Red, e.VisibleBounds.Left, e.VisibleBounds.Top, e.VisibleBounds.Left, e.VisibleBounds.Bottom);
        e.Graphics.DrawLine(Pens.Green, e.VisibleBounds.Right - 1, e.VisibleBounds.Top, e.VisibleBounds.Right - 1, e.VisibleBounds.Bottom);
    };

    grid.PaintColumnPanel += delegate(object sender, PaintColumnPanelEventArgs e)
    {
        e.PaintAll();
        e.Handled = true;

        //Draw a line before the first column
        e.Graphics.DrawLine(Pens.Green, e.Bounds.Left - 1, e.Bounds.Top, e.Bounds.Left - 1, e.Bounds.Bottom);

        //Draw a line after the last column
        e.Graphics.DrawLine(Pens.Red, e.SpaceAfterLastColumn.Left, e.SpaceAfterLastColumn.Top, e.SpaceAfterLastColumn.Left, e.SpaceAfterLastColumn.Bottom);
    };

     

    The next code demonstrates how to incrase spacing in cells:

     

    grid.Headers[0]["SomeColumn"].Appearance.CellTextSettings.Padding = new Padding(15, 0, 15, 0);

     

    Best regards,
    Dapfor

    0

Please sign in to leave a comment.

Powered by Zendesk