类型转换导致错误

本文关键字:错误 类型转换 | 更新日期: 2023-09-27 18:03:19

下面的代码导致一个错误,我明白为什么,但我不知道如何修复它:

public static Excel.Application CurrentApplication = new Excel.Application();
CurrentApplication.Cursor = Cursors.Default;

如何显式更改cursor . default的类型?

类型转换导致错误

光标。默认是windows窗体游标。你必须提供一个excel XlMousePointer:

public enum XlMousePointer
{
    xlDefault = -4143,
    xlNorthwestArrow = 1,
    xlWait = 2,
    xlIBeam = 3,
}

所以这行得通:(using Excel = Microsoft.Office.Interop.Excel;)

CurrentApplication.Cursor = Excel.XlMousePointer.xlDefault;