VS2010中关于ICON的一点知识

在看world wind时,遇到一个问题。查了好多资料,最后在老外的网站上终于找到了相关资料。保存一下

In .NET framework, the Icon class represents a Windows icon, which is a small bitmap image used to represent an object. The icon class is defined in System.Drawing namespace. So before using Icon class, you need to reference the System.Drawing namespace to your application.

You can set icon of a form at run-time as well as at design-time. You use a form's Icon property to set form's icon at design-time. Which actually adds two lines to your source code:

System.Resources.ResourceManager resources = new System.Resources.ResourceManager (typeof(Form1));
this.Icon = (System.Drawing.Icon) resources.GetObject ("$this.Icon");

Creating an Icon Object at run-time

You can can create an icon object at run-time and set it as icon of a Form. You use Icon constructor to create an icon object. The Icon constructor is an overloaded method:

In this sample example, I load tst.ico file as an icon of the form.

System.Drawing.Icon ico = new System.Drawing.Icon("c:\\temp\\tst.ico");
this.Icon = ico ;

You can even set icon's size by using other overloaded constructors.

转载于:https://www.cnblogs.com/findeasy/archive/2012/04/10/4053187.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值