Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 导致错误的类型转换_C#_Excel_Visual Studio 2012_Types_Vsto - Fatal编程技术网

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;