Reputation: 1590
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...
Upvotes: 2
Views: 2541
Reputation: 15196
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 :)
Upvotes: 1
Reputation: 8085
You'd have to draw the cells yourself to achieve this, using OwnerDraw.
Upvotes: 2