Image img = image.fromfile (@ "C:\Users\joeymary\Desktop\3.gif");
pictureBox1.Image =img. Clone () as Image;
Label1. Image = img. Clone () as Image;
Label1. Size = img. Size;
Img. Dispose ();
Label and PictureBox can be used in both.
Because the form redraw causes the control to blink
Method One:
<summary>
Rewrite the CreateParams property of the form to buffer the control two times (double buffer)
</summary>
protected override CreateParams createparams//! I can't believe it's not flashing.
{
Get
{
CreateParams CP = base. CreateParams;
Cp. ExStyle |= 0x02000000;
return CP;
}
}
The second method is to set the control's DoubleBuffered property, and you need to be aware that this property is private and that you need to use reflection to set this property.
This method has not been tried, after all, look dizzy
Public Static void Setdoublebuffered(System.Windows.Forms.ControlC){ Please refer to the blog below Http://blogs.msdn.com/oldnewthing/archive/2006/01/03/508694.aspx If (System.Windows.Forms.SystemInformation.Terminalserversession) Return; System.Reflection.PropertyInfoAprop= typeof(System.Windows.Forms.Control).GetProperty( "DoubleBuffered", System. Reflection. BindingFlags. NonPublic | System. Reflection. BindingFlags. Instance); aprop. SetValue(c, true, null); }< /c14>
This.panel1.BackColor = color.transparent;//Panel is set to transparent
This.panel1.Parent = this.picturebox1;//Sets the panel parent control as a background picture control
This.panel1.BringToFront ();//Put panel in front
Control to make the control (such as a panel) transparent when you add a GIF picture to it and use double buffering to make it blink and the background is GIF