GridView and line type

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
 
N

Nicholas Paldino [.NET/C# MVP]

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.
 
N

Nicholas Paldino [.NET/C# MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top