无法将类型 'System.Drawing.Image' 转换为 'System.Drawing.Icon'
Cannot convert type 'System.Drawing.Image' to 'System.Drawing.Icon'
我正在使用 VBUC 将 VB6 应用程序迁移到 C#,但出现此错误:
无法将类型 'System.Drawing.Image' 转换为 'System.Drawing.Icon'
我的代码是:
this.Icon = (Icon) ImageList1.Images[0];
this.Text = "Edit Existing Level";
解决这个问题最快的内存方法是什么?
我写了一个扩展方法,将图像转换为位图,然后再转换为图标:
public static class MyExtensions
{
public static System.Drawing.Icon ToIcon(this System.Drawing.Image instance)
{
using (System.Drawing.Bitmap bm = (System.Drawing.Bitmap)instance)
{
return System.Drawing.Icon.FromHandle(bm.GetHicon());
}
}
}
我正在使用 VBUC 将 VB6 应用程序迁移到 C#,但出现此错误:
无法将类型 'System.Drawing.Image' 转换为 'System.Drawing.Icon' 我的代码是:
this.Icon = (Icon) ImageList1.Images[0];
this.Text = "Edit Existing Level";
解决这个问题最快的内存方法是什么?
我写了一个扩展方法,将图像转换为位图,然后再转换为图标:
public static class MyExtensions
{
public static System.Drawing.Icon ToIcon(this System.Drawing.Image instance)
{
using (System.Drawing.Bitmap bm = (System.Drawing.Bitmap)instance)
{
return System.Drawing.Icon.FromHandle(bm.GetHicon());
}
}
}