0

In a Windows Forms application is a panel with a PictureBox on it; the image of that PictureBox is an animated gif.

If I set panel.Enabled = False, the animation stops.

What is the best way to keep the animation?

One way would be to override the OnPaint-Method and use ImageAnimator.Animate (something like described here I have a problem with a picturebox with animation gif, it is not move, by c# code)

I really hope there is a better way.

Tymur Gubayev
  • 468
  • 4
  • 14
  • Why do you need the PictureBox disabled? Users can't interact with it. – LarsTech Mar 02 '18 at 15:45
  • it's not the PictureBox that's disabled, it's some ancestor control of it. – Tymur Gubayev Mar 02 '18 at 15:46
  • There is no clean solution for this, the Enabled property is not virtual. Use ImageAnimator. – Hans Passant Mar 02 '18 at 16:02
  • Does that Panel actually need to be the PictureBox parent container? You could let the PictureBox parent be the Form and position/BringToFront() the image as needed. – Jimi Mar 03 '18 at 00:43
  • @Jimi unfortunately, It kind of does. It's a "loading indicator", and I'm trying to get it universally usable: I want to be able to call "ShowControlBusy" for any control. – Tymur Gubayev Mar 03 '18 at 12:16
  • Well, that wasn't clear at all, at least to me. Have you considered using an overlay for this? The suggested ImageAnimator can work as well. What is certain is that this "Busy indicator" control can't be the child of a disabled parent control. – Jimi Mar 03 '18 at 12:59

0 Answers0