dimanche 30 août 2020

Overridden CellPainting in DataGridView displays content only after cell loses focus

I have overridden the CellPainting in a WinForms DataGridView to display a specific image in a cell depending on various factors.

To give you some more details, in the CellPainting I am redrawing the content of a DataGricViewCheckBoxColumn; I want to display a green tick or red cross instead of the default black tick.

To draw the image I use:

e.Graphics.DrawImage(image, new PointF(centreX - offsetX, centreY - offsetY));

It works fine, but my green tick/red cross is only displayed after the cell loses focus. Is there a way to make it show as soon as I have clicked it, just like the standard checkbox does?

Thanks




Aucun commentaire:

Enregistrer un commentaire