给Windows组件添加图标
1.新建一个用户控件
2.向资源文件是添加一张图片,图片格式为bmp
3.选中用户控件图标,单击“右键->属性”把 “生成操作 的属性值改为:嵌入的资源(Action Resource)
4.
using System.Drawing;
namespace DeviceOperator
{
[ToolboxBitmap(typeof(Appearance), "Resources.Appearance.bmp")]
public partial class Appearance : System.IO.Ports.SerialPort
{
public Appearance()
{
InitializeComponent();
}
public Appearance(IContainer container)
{
container.Add(this);
InitializeComponent();
}
}
}
namespace DeviceOperator
{
[ToolboxBitmap(typeof(Appearance), "Resources.Appearance.bmp")]
public partial class Appearance : System.IO.Ports.SerialPort
{
public Appearance()
{
InitializeComponent();
}
public Appearance(IContainer container)
{
container.Add(this);
InitializeComponent();
}
}
}