Question

Does anyone know how to change the Bordercolor for a Datagridviewcell in c#?

Here's a picture of what I mean:

Datagridviewstyle http://www.zivillian.de/datagridview.png Picture

Backgroundcolor, Textcolor and Images are no Problem, but I don't know how to realise the Borders.

EDIT: I want to realise this with winforms.

Another problem is the cross in the second Row, but that's for later...

Was it helpful?

Solution

You'd have to draw the cells yourself to achieve this, using OwnerDraw.

OTHER TIPS

You can hook up on two events on your datagridview. 'ItemCreated' and 'ItemDatabound' Each will pass you an eventarg that can access your itemtemplate. Within that you can .FindControl("ControlId") or step through the .Controls collections to find the cell. Once you got that cell you can do whatever you want - both bordercolor and the cross. ItemCreated will fire for each drawing (postback) while ItemDatabound only when you databind :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top