Image view refresh issue

Hello everyone,
I’m having an issue with the refresh of a ImageView control. When I set it’s content with a bitmap I draw on with a Graphics the image turns completely black, and only if I resize the panel which contains it I get to see the correct content. I do something like this

// m_graphPreview is a ImageView 
var bmp = new Bitmap(m_graphPreview.Size, PixelFormat.Format32bppRgb);
using (var g = new Graphics(bmp)) {
  // Generate image sampling some curve and then using g.DrawLines(pen, polyline.ToArray());
  m_graphPreview.Image = bmp;
}

Am I doing something wrong?

Thanks

@m.camillo,

Can you share a little more code? It could be a number of things and it’s hard to repro with your snippet.

I’d try:

  • move m_graphPreview.Image = bmp; outside the using
  • use g.Clear(Colors.Red) at the start of your using, does the box get set to red, or is it still black?

I moved the Image set outside of the using and it works, thank you