zoukankan      html  css  js  c++  java
  • 项目资源文件的添加与使用

    在项目使用的图片,字符串等资源文件,在使用前首先添加到项目的资源文件,在使用时使用如下命令进行添加:

    this.imageList1.ImageStream = ((ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));

    以上命令添加了一个imagelist资源。把图片资源从资源文件获取来,添加到程序界面。

    this.imageList1.Images.SetKeyName(0, "close");

    使用以上命令指定使用哪一个图片文件。

    同时也可以使用控件自带的添加图片的功能,右键点击该控件,选择添加图片添加图片。但是使用资源文件的方式使得整个程序更加的统一,利于管理。而且可以再其他界面对资源文件进行多次的重复使用。因此本人推荐使用资源文件。

    资源文件的添加很简单,打开项目,双击property文件夹,就会弹出项目的属性,选择资源,就出现了项目包含的所有资源文件。按照资源的类型进行添加。比如要添加图片,选择资源类型为图片,然后找到要添加的图片,拖入该窗口即可。 

                this.imageList1.ImageStream = ((ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
    
                this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
    
                this.imageList1.Images.SetKeyName(0, "close");
    
                this.imageList1.Images.SetKeyName(1, "max");
    
                this.imageList1.Images.SetKeyName(2, "min");
    
                this.imageList1.Images.SetKeyName(3, "normal");
    
                this.imageList1.Images.SetKeyName(4, "CameraDisconn");
    
                this.imageList1.Images.SetKeyName(5, "CameraConn");
    
                this.imageList1.Images.SetKeyName(6, "CameraSeach");
    
                this.imageList1.Images.SetKeyName(7, "IOSearch");
    
                this.imageList1.Images.SetKeyName(8, "IOCon.bmp");
    
                this.imageList1.Images.SetKeyName(9, "IODiscon.bmp");
    
                this.imageList1.Images.SetKeyName(10, "search.bmp");
    
                this.imageList1.Images.SetKeyName(11, "right.bmp");
    
                this.imageList1.Images.SetKeyName(12, "err.bmp");
    
                this.imageList1.Images.SetKeyName(13, "waiting.bmp");
    View Code

    以上是两种方式使用图片资源,8之前使用的是项目的资源文件,8以后使用的是控件自带的添加图片的方法使用图片资源。

    您的资助是我最大的动力!
    金额随意,欢迎来赏!
    付款后有任何问题请给我留言。

    如果,您认为阅读这篇博客让您有些收获,不妨点击一下右下角的推荐按钮。
    如果,您希望更容易地发现我的新博客,不妨点击一下绿色通道的关注我

    如果,想给予我更多的鼓励,求打

    因为,我的写作热情也离不开您的肯定支持,感谢您的阅读,我是【火锅商人】!

  • 相关阅读:
    思维发散的双刃剑
    一个请求过来都经过了什么?(Thrift版)
    业务开发转基础开发,这三种「高可用」架构你会么?
    程序常用的设计技巧
    美团分布式服务通信框架及服务治理系统OCTO
    《程序员修炼之道》解读
    面试官说:你真的不是不优秀只是不合适
    架构视角-文件的通用存储原理
    那些影响深远的弯路
    iOS sqlite ORM框架-LKDBHelper
  • 原文地址:https://www.cnblogs.com/swads/p/9540049.html
Copyright © 2011-2022 走看看