Gmnd-i
Gmnd-i

Reputation: 125

How not to show hand cursor on links in web browser?

In web browser of Visual C#, if the user moves the cursor on to the link, the cursor would be changed into a hand automatically.. I want to change this.. I want to make my program not to show hand if user moves the cursor on to a link in the web browser of my program.. I checked all the web browser properties in visual C# and I couldn't find any settings to do it.. Is it possible or not ?

If it is, how can I do it ?

Thanks !

Upvotes: 0

Views: 338

Answers (1)

NibblyPig
NibblyPig

Reputation: 52942

You can do this by injecting a CSS rule into the browser control.

What you want to do is add the style/css property cursor:default

You can do this by injecting a style element into the head section:

HtmlElement headTag = webBrowser1.Document.GetElementsByTagName("head")[0];
HtmlElement styleEl = webBrowser1.Document.CreateElement("style");
IHTMLStyleElement element = (IHTMLStyleElement)styleEl.DomElement;
IHTMLStyleSheetElement styleSheet = element.styleSheet;
styleSheet.cssText = @"a { cursor: default }";
head.AppendChild(styleEl);

Upvotes: 1

Related Questions