项目文件夹F 里有图片 img1.gif 
如何通过代码设置 img1.gif 为  窗体Form1 的背景图片?Form1.backgroundImage 如何给它赋值??

解决方案 »

  1.   

    Form1 f = new Form1();
    f.BackgroundImage = Image.FromFile(System.IO.Path.GetFullPath("1.jpg"));
      

  2.   


    就当前项目中有个文件夹 F 有图片 img1.gif  了。
    我这么写可以么:f.BackgroundImage = Image.FromFile(System.IO.Path.GetFullPath("相对路径"));或者又要如何写?
      

  3.   


    把F这个文件夹丢到Bin/DeBug下面 然后直接写System.IO.Path.GetFullPath("../f/img1.gif")
      

  4.   


    不丢的话 直接时System.IO.Path.GetFullPath("../../F/img1.gif");
      

  5.   

     把F这个文件夹丢到Bin/DeBug下面 
    f.BackgroundImage = Image.FromFile(Application.StartupPath +"\\1.jpg"));f.BackgroundImage = Image.FromFile(Application.StartupPath +"\\f\\1.jpg"));