Cell border
Hi, how can I set the border to visible as following
I tried to paint manually at OnPaintCell but it painted at the back of the cell.
Pen pn = new Pen(Color.Blue);
Rectangle rect2 = new Rectangle(e.Cell.VisibleBounds.X, e.Cell.VisibleBounds.Location.Y, e.Cell.VisibleBounds.Width, e.Cell.VisibleBounds.Height);
e.Graphics.DrawRectangle(pn, rect2);
pn.Dispose();
border.png
0
-
Hi,
You have two possibilities to do it :
1. By setting Grid.Appearance properties:
grid.Appearance.VerticalLines = true;
grid.Appearance.VerticalLinesColor = Color.Blue;
grid.Appearance.HorizontalLines = true;
grid.Appearance.HorizontalLinesColor = Color.Blue;
2. By implementing Grid.PaintCell event :
grid.PaintCell += delegate(object sender, PaintCellEventArgs e)
{
//Do default drawing
e.PaintAll();
e.Handled = true;
//Do custom drawing
using(Pen pn = new Pen(Color.Blue))
{
Rectangle rect2 = new Rectangle(e.Cell.VisibleBounds.X, e.Cell.VisibleBounds.Location.Y, e.Cell.VisibleBounds.Width, e.Cell.VisibleBounds.Height);
e.Graphics.DrawRectangle(pn, rect2);
pn.Dispose();
}
};
Best regards,
The Dapfor Team0
Please sign in to leave a comment.
Comments
1 comment