VB.Net / VB 如何隱藏 WebBrowser 控件 中之捲軸

VB.Net / VB 如何隱藏 WebBrowser 控件 中之捲軸

VB.Net / VB 如何隱藏 WebBrowser 控制項 (元件) 中之捲軸

由於 WebBrowser 控制項元件 並未提供 捲軸設定的屬性 , 因此必須自行處理囉 !

<< VB.Net 寫法 >>

Private Sub WebBrowser1_DocumentCompleted _

(ByVal sender As System.Object, ByVal e As WebBrowserDocumentCompletedEventArgs) Handles _

WebBrowser1.DocumentCompleted

' 當 WebBrowser 中的 HTML Document (物件) 載入完成後 , 設定其 "不顯示" 捲軸

If sender.Document <> Nothing Then sender.Document.Body.SetAttribute("scroll", "no")

End Sub

================================================================

<< VB.Net 使用 COM 元件 Microsoft Web Browser 寫法 >>

Private Sub AxWebBrowser1_DocumentComplete _

(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent) _

Handles AxWebBrowser1.DocumentComplete

sender.Document.Body.SetAttribute("scroll", "no")

End Sub

================================================================

<< VB6 寫法 >>

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)

' 當 WebBrowser 中的Document 載入完成後 , 設定其 "隱藏" 捲軸

If Not WebBrowser1.Document Is Nothing Then WebBrowser1.Document.body.setAttribute "scroll", "no"

End Sub