Column panel borders + spacing between cell border and content
Hi,
Is there a way to changed the colour that the column headers are painted? They seem to be stuck on white as circled in red in the picture. Also is it possible to increase the spacing between the left (or right if cell right-aligned) edge of a grid cell and the text that it contains? I've circled this area in blue.
Thanks
Josh
grid.png
0
-
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,
Dapfor0
Please sign in to leave a comment.
Comments
1 comment