Hello,
I am trying to understand difference between CellFormatting and CellPainting event in DatagridView for a scenario where I want to set backgroundcolor of a cell by using some condition regarding CellValue.
I tried both approaches (to format background) in CellFormatting and CellPainting event, and both seems to work fine...
I know what is a general usage of CellFormatting and CellParsing Event, and also i understand that in CellPainting event i can make some drawing of cell, not just set a color, but for my task, is there any difference where should i implement my coloring?
I saw in MSDN article how they use it in Cell formatting event
If ((stringValue.IndexOf("pink") > -1))Then
e.CellStyle.BackColor = Color.Pink
End If
One more thing, maybe worth to mention, my datagridview is bound to my Dataset.Datatable with a bindingSource.
Whenever table data gets changed (by using datagridview control to edit value, or by using a code to update directly some table value), backgroundcolor check condition should be executed.
Thank You very much in advance
Milos