使用其他类的IntPtr

时间:2020-10-20 11:56:46

标签: c#

我正在为文本框使用自定义光标

这种方法对我来说很好用

[DllImport("user32.dll")]
static extern IntPtr LoadCursorFromFile(string lpFileName);
IntPtr Search_cursor = LoadCursorFromFile(Application.StartupPath + "\\SearchCursor.cur");

txt_Vacation_Calculate_Type_Code.Cursor = new Cursor(Search_cursor);

但是我需要使用其他类的方法 我已经创建了Image_Icon

class Image_Icon
{
[DllImport("user32.dll")]
static extern IntPtr LoadCursorFromFile(string lpFileName);

public IntPtr Search_cursor_C()
{
IntPtr Search_cursor = LoadCursorFromFile(Application.StartupPath + "\\SearchCursor.cur");
return (Search_cursor);
}

我正在使用此代码获取光标

txt_Vacation_Calculate_Type_Code.Cursor = new Cursor(Image_Icon.Search_cursor_C);

但是看起来有些问题 我收到此错误

严重性代码描述项目文件行抑制状态 错误CS1503参数1:无法从“方法组”转换为“ IntPtr” PayRoll C:\ Users \ Ahmed Abdo \ Desktop \ WorkNow \ PayRoll \ PayRoll \ PayRoll \ Basis \ frmEmployeeData.cs 68有效

如何从其他班级使用搜索光标访问该班级

1 个答案:

答案 0 :(得分:0)

将函数设为静态,然后返回<div>example</div>

&lt;div&gt;example&lt;/div&gt;

然后像这样使用它:

Cursor
相关问题