首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在自定义控件中更改光标?

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

Stack Overflow用户
提问于 2013-04-25 13:48:20
回答 1查看 1K关注 0票数 1

这是我的自定义WebBrowser control

代码语言:javascript
复制
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");
}
}

如何将此controlcursor更改为我的embedded .ico。我用谷歌搜索了一下,找不到任何关于custom controls的信息。

谢谢。

EN

回答 1

Stack Overflow用户

发布于 2013-04-25 14:41:22

光标始终由Cursor属性更改。如果您有一个自定义控件,这并不重要。

试试这个:

代码语言:javascript
复制
Icon ico = new Icon(@"C:\temp\someIcon.ico");
this.Cursor = new Cursor(ico.Handle);

静态类System.Windows.Forms.Cursors包含所有系统游标。

要切换回默认系统光标,请使用以下命令:

代码语言:javascript
复制
this.Cursor = System.Windows.Forms.Cursors.Default;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16207252

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档