0

I have recently started using WebView2 in my application to show SSRS reports. When I used WebBrowser it was very easy to hide the scroll bars but WebVIew2 is not so obvious. I have found the following code, is this best way to hide scroll bars or is there a better approach?

Thanks

 Private Sub WebView2_NavigationCompleted(sender As Object, e As CoreWebView2NavigationCompletedEventArgs) Handles WebView21.NavigationCompleted, WebView22.NavigationCompleted
    If e.IsSuccess Then
        CType(sender, WebView2).ExecuteScriptAsync("document.querySelector('body').style.overflow='hidden'")
    End If
End Sub
Greg
  • 35
  • 1
  • 7

1 Answers1

0

Yes and No. Your javascript question about the scroll bars maybe correct but have a look at for example How to hide the scrollbar using JavaScript

Now the issue I see is that calling this on navigation complete could be too early for the HTML to be ready for you injection.

I would suggest you wait until DOMContentLoaded Event before executing your script.

darbid
  • 2,545
  • 23
  • 55