本文整理汇总了VB.NET中System.Windows.Forms.WebBrowser.Navigate方法的典型用法代码示例。如果您正苦于以下问题:VB.NET WebBrowser.Navigate方法的具体用法?VB.NET WebBrowser.Navigate怎么用?VB.NET WebBrowser.Navigate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.WebBrowser
的用法示例。
在下文中一共展示了WebBrowser.Navigate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: Navigate
' Navigates to the URL in the address box when
' the ENTER key is pressed while the ToolStripTextBox has focus.
Private Sub toolStripTextBox1_KeyDown( _
ByVal sender As Object, ByVal e As KeyEventArgs) _
Handles toolStripTextBox1.KeyDown
If (e.KeyCode = Keys.Enter) Then
Navigate(toolStripTextBox1.Text)
End If
End Sub
' Navigates to the URL in the address box when
' the Go button is clicked.
Private Sub goButton_Click( _
ByVal sender As Object, ByVal e As EventArgs) _
Handles goButton.Click
Navigate(toolStripTextBox1.Text)
End Sub
' Navigates to the given URL if it is valid.
Private Sub Navigate(ByVal address As String)
If String.IsNullOrEmpty(address) Then Return
If address.Equals("about:blank") Then Return
If Not address.StartsWith("http://") And _
Not address.StartsWith("https://") Then
address = "http://" & address
End If
Try
webBrowser1.Navigate(New Uri(address))
Catch ex As System.UriFormatException
Return
End Try
End Sub
' Updates the URL in TextBoxAddress upon navigation.
Private Sub webBrowser1_Navigated(ByVal sender As Object, _
ByVal e As WebBrowserNavigatedEventArgs) _
Handles webBrowser1.Navigated
toolStripTextBox1.Text = webBrowser1.Url.ToString()
End Sub
示例2: WebBrowserDemo
' 导入命名空间
Imports System.Windows.Forms
public class WebBrowserDemo
public Shared Sub Main
Application.Run(New Form1)
End Sub
End class
Public Class Form1
Private Sub txtURL_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtURL.KeyDown
If (e.KeyCode = Keys.Enter) Then
WebBrowser1.Navigate(txtURL.Text)
End If
End Sub
Private Sub btnBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBack.Click
WebBrowser1.GoBack()
End Sub
Private Sub btnForward_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnForward.Click
WebBrowser1.GoForward()
End Sub
Private Sub btnHome_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHome.Click
WebBrowser1.GoHome()
End Sub
End Class
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
Inherits System.Windows.Forms.Form
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.ToolStrip1 = New System.Windows.Forms.ToolStrip
Me.ToolStripLabel1 = New System.Windows.Forms.ToolStripLabel
Me.txtURL = New System.Windows.Forms.ToolStripTextBox
Me.btnBack = New System.Windows.Forms.ToolStripButton
Me.btnForward = New System.Windows.Forms.ToolStripButton
Me.btnHome = New System.Windows.Forms.ToolStripButton
Me.WebBrowser1 = New System.Windows.Forms.WebBrowser
Me.ToolStrip1.SuspendLayout()
Me.SuspendLayout()
Me.ToolStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripLabel1, Me.txtURL, Me.btnBack, Me.btnForward, Me.btnHome})
Me.ToolStrip1.Location = New System.Drawing.Point(0, 0)
Me.ToolStrip1.Size = New System.Drawing.Size(703, 25)
Me.ToolStripLabel1.Size = New System.Drawing.Size(50, 22)
Me.ToolStripLabel1.Text = "Address:"
Me.txtURL.Size = New System.Drawing.Size(200, 25)
Me.btnBack.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text
Me.btnBack.ImageTransparentColor = System.Drawing.Color.Magenta
Me.btnBack.Name = "btnBack"
Me.btnBack.Size = New System.Drawing.Size(33, 22)
Me.btnBack.Text = "Back"
'
'btnForward
'
Me.btnForward.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text
Me.btnForward.ImageTransparentColor = System.Drawing.Color.Magenta
Me.btnForward.Name = "btnForward"
Me.btnForward.Size = New System.Drawing.Size(51, 22)
Me.btnForward.Text = "Forward"
'
'btnHome
'
Me.btnHome.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text
Me.btnHome.ImageTransparentColor = System.Drawing.Color.Magenta
Me.btnHome.Name = "btnHome"
Me.btnHome.Size = New System.Drawing.Size(38, 22)
Me.btnHome.Text = "Home"
'
'WebBrowser1
'
Me.WebBrowser1.Dock = System.Windows.Forms.DockStyle.Fill
Me.WebBrowser1.Location = New System.Drawing.Point(0, 25)
Me.WebBrowser1.MinimumSize = New System.Drawing.Size(20, 20)
Me.WebBrowser1.Name = "WebBrowser1"
Me.WebBrowser1.Size = New System.Drawing.Size(703, 429)
Me.WebBrowser1.TabIndex = 1
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(703, 454)
Me.Controls.Add(Me.WebBrowser1)
Me.Controls.Add(Me.ToolStrip1)
Me.Name = "Form1"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "MyBrowser"
Me.ToolStrip1.ResumeLayout(False)
Me.ToolStrip1.PerformLayout()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents ToolStrip1 As System.Windows.Forms.ToolStrip
Friend WithEvents WebBrowser1 As System.Windows.Forms.WebBrowser
Friend WithEvents ToolStripLabel1 As System.Windows.Forms.ToolStripLabel
Friend WithEvents txtURL As System.Windows.Forms.ToolStripTextBox
Friend WithEvents btnBack As System.Windows.Forms.ToolStripButton
Friend WithEvents btnForward As System.Windows.Forms.ToolStripButton
Friend WithEvents btnHome As System.Windows.Forms.ToolStripButton
End Class