如何:在运行时设置图片 您所在的位置:网站首页 隐私信息怎么设置方法图片 如何:在运行时设置图片

如何:在运行时设置图片

2024-06-19 23:17| 来源: 网络整理| 查看: 265

使用 Image 类的 FromFile 方法设置 Image 属性。

在下例中,为图像位置设置的路径是 My Documents 文件夹。 这样做是出于一个假定,即假定大多数运行 Windows 操作系统的计算机都包含此目录。 这还使得具有最低系统访问级别的用户能够安全运行应用程序。 以下示例假定窗体已添加控件 PictureBox。

Private Sub LoadNewPict() ' You should replace the bold image ' in the sample below with an icon of your own choosing. PictureBox1.Image = Image.FromFile _ (System.Environment.GetFolderPath _ (System.Environment.SpecialFolder.Personal) _ & "\Image.gif") End Sub private void LoadNewPict(){ // You should replace the bold image // in the sample below with an icon of your own choosing. // Note the escape character used (@) when specifying the path. pictureBox1.Image = Image.FromFile (System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal) + @"\Image.gif"); } private: void LoadNewPict() { // You should replace the bold image // in the sample below with an icon of your own choosing. pictureBox1->Image = Image::FromFile(String::Concat( System::Environment::GetFolderPath( System::Environment::SpecialFolder::Personal), "\\Image.gif")); }


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有