1

I'm using ImageColumn in datagridview to view PNG Pictures saved in DB. Whenever I change tabs in my Form and go back to the Tab with DGV the PNG imgae transparent background keeps the drawing of the previous Control that was displayed in the same location. Also When I tried to change the Image and save a New PNG image the DGV is updated and it displays parts of the previous picture in the transparent part. I change Background color and SelectionBackground color in the imageColumn cell default style options to WHITE but nothing is changed. Can any body help me to solve this issue? Please see pictures for clearance.. enter image description here

Shoshotto
  • 93
  • 2
  • 8

1 Answers1

0

Finally Solved by code!

Used CellPaining to draw a white rectangle in the cell.

Private Sub ItemsList_CellPainting(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellPaintingEventArgs) Handles ItemsList.CellPainting
        If ItemsList.Columns(e.ColumnIndex).Name = "iconCol" And e.RowIndex >= 0 Then
            e.Paint(e.CellBounds, DataGridViewPaintParts.All)
            e.Graphics.FillRectangle(Brushes.White, e.CellBounds.Left, e.CellBounds.Top, e.CellBounds.Width, e.CellBounds.Height)
        End If

Don't use DrawRectangle use FillRecangle to draw the rectangle so the background is filled with the color.

Shoshotto
  • 93
  • 2
  • 8