.net - change datagridview cellstyle border color -
i trying change cell border colors based on background color of cell
this have used
'draw custom cell borders. using brush new solidbrush(grdlist.columnheadersdefaultcellstyle.backcolor) e.graphics.fillrectangle(brush, e.cellbounds) end using e.paint(e.cellbounds, datagridviewpaintparts.all , not datagridviewpaintparts.contentbackground) debug.print(e.cellstyle.backcolor.tostring) controlpaint.drawborder(e.graphics, e.cellbounds, e.cellstyle.backcolor, 1, _ buttonborderstyle.solid, e.cellstyle.backcolor, 1, _ buttonborderstyle.solid, e.cellstyle.backcolor, 1, _ buttonborderstyle.solid, color.black, 1, _ buttonborderstyle.solid)
this result
i dont white lines seen
as option can set border styles yo none:
me.datagridview1.cellborderstyle = datagridviewcellborderstyle.none
then handle cellpainting
event , paint borders:
private sub datagridview1_cellpainting(sender object, _ e datagridviewcellpaintingeventargs) handles datagridview1.cellpainting if (e.columnindex < 0 orelse e.rowindex < 0) return e.paint(e.cellbounds, datagridviewpaintparts.all) dim r = e.cellbounds e.graphics.drawline(pens.black, r.left, r.top, r.right, r.top) e.graphics.drawline(pens.black, r.left, r.bottom, r.right, r.bottom) e.handled = true end sub
Comments
Post a Comment