GridView and line type

  • Thread starter Thread starter R.A.F.
  • Start date Start date
R

R.A.F.

Hi,

I would like to paint the gridline of my DataGridView not as solid, but
as Dash line for example.

I did not see any property to do that, therefore how can i perform this
task ?

thanks a lot,

RAF
 
RAF,

You can't, at least without custom painting. If you want to draw a
dashed line, you will have to set the border style of the grid to None, and
then draw the dashed lines in the space where the border would be.
Fortunately, it does not look like the grid changes its size when you change
the border style, so the space where the border would be should be empty
when you set the border style to none.

To draw the dashes, you will want to create a Pen to use with the
DrawRectangle method on the Graphics instance passed to your event handler
(or OnPaint method). On that Pen instance, you would change the DashStyle
property to one of the values in the DashStyle enumeration, most likely
DashStyle.Dash or DashStyle.Dot.
 
No, not really. You can call the base implementation, and then draw
OVER that. Since you are just drawing a border, you shouldn't have a
problem.
 
Back
Top