C# 导致错误的类型转换
以下代码导致错误,我理解原因,但不知道如何修复:C# 导致错误的类型转换,c#,excel,visual-studio-2012,types,vsto,C#,Excel,Visual Studio 2012,Types,Vsto,以下代码导致错误,我理解原因,但不知道如何修复: public static Excel.Application CurrentApplication = new Excel.Application(); CurrentApplication.Cursor = Cursors.Default; 如何显式更改游标的类型。默认值?游标。默认值是windows窗体游标。您必须提供excel XlMousePointer: public enum XlMousePointer { xlDefa
public static Excel.Application CurrentApplication = new Excel.Application();
CurrentApplication.Cursor = Cursors.Default;
如何显式更改游标的类型。默认值?游标。默认值是windows窗体游标。您必须提供excel XlMousePointer:
public enum XlMousePointer
{
xlDefault = -4143,
xlNorthwestArrow = 1,
xlWait = 2,
xlIBeam = 3,
}
所以这是可行的:
(使用Excel=Microsoft.Office.Interop.Excel;)
什么错误?有一点很清楚,您需要包装
CurrentApplication.Cursor=Cursors.Default代码>在方法中。是的,它被包装在方法中。错误是:无法将类型“System.Windows.Forms.Cursor”隐式转换为“Microsoft.Office.Interop.Excel.XIMousePointer”哦,太酷了。非常感谢。如果我想分配我自己的custom cursor.cur文件,或者更好的是,有没有办法将system.windows.forms.cursors图像之一转换为x1,以便我可以在此处分配它?
CurrentApplication.Cursor = Excel.XlMousePointer.xlDefault;