C# 如何在自定义控件中更改光标?

C# 如何在自定义控件中更改光标?,c#,.net,winforms,cursor,browser,C#,.net,Winforms,Cursor,Browser,这是我的自定义WebBrowser控件 using System; using System.Text.RegularExpressions; using System.Windows.Forms; public class RunescapeClient : WebBrowser { private const string RUNESCAPE_CLIENT_URL = "http://oldschool33.runescape.com/j1"; public RunescapeCli

这是我的自定义
WebBrowser控件

using System;
using System.Text.RegularExpressions;
using System.Windows.Forms;

public class RunescapeClient : WebBrowser
{
  private const string RUNESCAPE_CLIENT_URL = "http://oldschool33.runescape.com/j1";

public RunescapeClient()
{
    ScrollBarsEnabled = false;
    ScriptErrorsSuppressed = true;
    IsWebBrowserContextMenuEnabled = false;
    AllowWebBrowserDrop = false;
    Navigate(RUNESCAPE_CLIENT_URL);
}

protected override void OnDocumentCompleted(WebBrowserDocumentCompletedEventArgs e)
{
    if (Document != null && ValidClientUrl(e.Url.ToString()))
    {
        HtmlElement tableElement = Document.GetElementsByTagName("table")[1];
        tableElement.InnerText = string.Empty;
    }
}

private static bool ValidClientUrl(string url)
{
    return Regex.IsMatch(url, @"http://oldschool\d{1,2}.runescape.com/j1");
}
}
如何将此
控件的
光标更改为my
embedded.ico
。我在谷歌上搜索,找不到任何有关
自定义控件的内容


谢谢。

光标始终由
光标
属性更改。是否有自定义控件并不重要

试试这个:

Icon ico = new Icon(@"C:\temp\someIcon.ico");
this.Cursor = new Cursor(ico.Handle);
静态类
System.Windows.Forms.Cursors
包含所有系统游标。
要切换回默认系统光标,请使用以下命令:

this.Cursor = System.Windows.Forms.Cursors.Default;

您的问题是更改图标,而不是(鼠标)-光标?由于WebBrowser控件只有默认图标可用,如何用资源中的自定义.ICO文件替换默认光标。“WebBrowser控件不支持光标属性。”我该如何解决此问题?我的问题
是包含WebBrowser控件的表单。因此,您可以使用
this.TopLevelControl.Cursor
更改光标。我感谢您的帮助;但是,它不起作用。当鼠标位于WebBrowser控件之外时,它会工作,但是,当鼠标放置在WebBrowser控件上时,它会切换回默认光标**编辑:this.TopLevelControl.Cursor也不会。