n.Mehta n.Mehta - 4 months ago 8
Vb.net Question

How to disable clicking WebBroswer, but still able to scroll WebBroswer

I have a WebBrowser in my VB.net form. I want to disable from users clicking links in the WebBroswer, but still able to scroll the WebBroswer.

I found this code but it locks up the whole WebBroswers so I can't click links or scroll, but i need to be able to scroll
DirectCast(WebBrowser1, Control).Enabled = False

Answer

Just set the following property:

WebBrowser1.AllowNavigation = False

A hacky work-around to change the address from code would be to turn AllowNavigation on again, but it requires a BeginInvoke to allow the navigation to take place before turning it off again:

WebBrowser1.AllowNavigation = True
WebBrowser1.Navigate("new web address...")
Me.BeginInvoke(New Action(Sub() WebBrowser1.AllowNavigation = False))
Comments