Using a WebBrowser control in my Windows Forms application, I want to retrieve the information, whether a horizontal scrollbar is currently being shown.
E.g. I want to create a function/property, let’s call it “HasHorzontalScrollbar“, that either returns true or false:

I’ve tried to use Spy++ to inspect the window and I tried to read the size from the window similar the following, but I’m still unable to get meaningful values:
var height1 = webBrowser1.Document.Window.Size.Height;
var height2 = webBrowser1.Height;
My question is:
Is there a way to query the WebBrowser whether the horizontal scrollbar is currently visible?
Edit: Solved
Thanks to the help from Yahia, I was able to develop a solution:
public bool HasHorizontalScrollbar
{
get
{
var width1 = webBrowser.Document.Body.ScrollRectangle.Width;
var width2 = webBrowser.Document.Window.Size.Width;
return width1 > width2;
}
}
This works in my test environment.
try
see MSDN.