如何在Windows窗体中插入GIF文件 [英] How to insert GIF file in windows Form

查看:110
本文介绍了如何在Windows窗体中插入GIF文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Windows Form

How to insert GIF file in windows Form

推荐答案

System.Windows.Forms命名空间中的PictureBox类中插入GIF文件将解决此问题.这是示例代码:

PictureBox class in System.Windows.Forms namespace will resolve this issue. Here is the sample code:

private Bitmap MyImage ;
public void ShowMyImage(String fileToDisplay, int xSize, int ySize)
{
   // Sets up an image object to be displayed.
   if (MyImage != null)
   {
      MyImage.Dispose();
   }

   // Stretches the image to fit the pictureBox.
   pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage ;
   MyImage = new Bitmap(fileToDisplay);
   pictureBox1.ClientSize = new Size(xSize, ySize);
   pictureBox1.Image = (Image) MyImage ;
}


这篇关于如何在Windows窗体中插入GIF文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆