filmov
tv
VB 2008 guter Webbrowser
Показать описание
Hier zeige ich euch wie man einen guten aber leicht zu programmierenden Webbrowser programmiert.
Ich habe die Beschriftung mal in Englisch gemacht damit alle es verstehen =).
Hier noch mal der Code :
Public Class Form1
Dim int As Integer = 0
Private Sub Loading(ByVal sender As Object, ByVal e As Windows.Forms.WebBrowserProgressChangedE ventArgs)
ToolStripProgressBar1.Maximum = e.MaximumProgress
ToolStripProgressBar1.Value = e.CurrentProgress
End Sub
Private Sub Done(ByVal sender As Object, ByVal e As Windows.Forms.WebBrowserDocumentComplete dEventArgs)
TabControl1.SelectedTab.Text = CType(TabControl1.SelectedTab.Controls.I tem(0), WebBrowser).DocumentTitle
ComboBox1.Text = CType(TabControl1.SelectedTab.Controls.I tem(0), WebBrowser).Url.ToString
End Sub
Form1_Load:
Dim Browser As New WebBrowser
TabControl1.TabPages.Add("New Page")
Browser.Name = "Web Browser"
Browser.Dock = DockStyle.Fill
TabControl1.SelectedTab.Controls.Add(Bro wser)
AddHandler Browser.ProgressChanged, AddressOf Loading
AddHandler Browser.DocumentCompleted, AddressOf Done
int = int + 1
CType(TabControl1.SelectedTab.Controls.I tem(0), WebBrowser).GoHome()
Add Tab:
Dim Browser As New WebBrowser
TabControl1.TabPages.Add("New Page")
TabControl1.SelectTab(int)
Browser.Name = "Web Browser"
Browser.Dock = DockStyle.Fill
TabControl1.SelectedTab.Controls.Add(Bro wser)
AddHandler Browser.ProgressChanged, AddressOf Loading
AddHandler Browser.DocumentCompleted, AddressOf Done
int = int + 1
CType(TabControl1.SelectedTab.Controls.I tem(0), WebBrowser).GoHome()
Remove Tab:
If Not TabControl1.TabPages.Count = 1 Then
TabControl1.TabPages.RemoveAt(TabControl 1.SelectedIndex)
TabControl1.SelectTab(TabControl1.TabPag es.Count - 1)
int = int - 1
End If
Website Properties:
CType(TabControl1.SelectedTab.Controls.I tem(0), WebBrowser).ShowPropertiesDialog
Back:
CType(TabControl1.SelectedTab.Controls.I tem(0), WebBrowser).GoBack()
Forward:
CType(TabControl1.SelectedTab.Controls.I tem(0), WebBrowser).GoForward()
Refresh:
CType(TabControl1.SelectedTab.Controls.I tem(0), WebBrowser).Refresh()
Stop:
CType(TabControl1.SelectedTab.Controls.I tem(0), WebBrowser).Stop()
Home:
CType(TabControl1.SelectedTab.Controls.I tem(0), WebBrowser).GoHome()
Go:
CType(TabControl1.SelectedTab.Controls.I tem(0), WebBrowser).Navigate(ComboBox1.Text)
Timer1:
ToolStripStatusLabel1.Text = CType(TabControl1.SelectedTab.Controls.I tem(0), WebBrowser).StatusText
Ich habe die Beschriftung mal in Englisch gemacht damit alle es verstehen =).
Hier noch mal der Code :
Public Class Form1
Dim int As Integer = 0
Private Sub Loading(ByVal sender As Object, ByVal e As Windows.Forms.WebBrowserProgressChangedE ventArgs)
ToolStripProgressBar1.Maximum = e.MaximumProgress
ToolStripProgressBar1.Value = e.CurrentProgress
End Sub
Private Sub Done(ByVal sender As Object, ByVal e As Windows.Forms.WebBrowserDocumentComplete dEventArgs)
TabControl1.SelectedTab.Text = CType(TabControl1.SelectedTab.Controls.I tem(0), WebBrowser).DocumentTitle
ComboBox1.Text = CType(TabControl1.SelectedTab.Controls.I tem(0), WebBrowser).Url.ToString
End Sub
Form1_Load:
Dim Browser As New WebBrowser
TabControl1.TabPages.Add("New Page")
Browser.Name = "Web Browser"
Browser.Dock = DockStyle.Fill
TabControl1.SelectedTab.Controls.Add(Bro wser)
AddHandler Browser.ProgressChanged, AddressOf Loading
AddHandler Browser.DocumentCompleted, AddressOf Done
int = int + 1
CType(TabControl1.SelectedTab.Controls.I tem(0), WebBrowser).GoHome()
Add Tab:
Dim Browser As New WebBrowser
TabControl1.TabPages.Add("New Page")
TabControl1.SelectTab(int)
Browser.Name = "Web Browser"
Browser.Dock = DockStyle.Fill
TabControl1.SelectedTab.Controls.Add(Bro wser)
AddHandler Browser.ProgressChanged, AddressOf Loading
AddHandler Browser.DocumentCompleted, AddressOf Done
int = int + 1
CType(TabControl1.SelectedTab.Controls.I tem(0), WebBrowser).GoHome()
Remove Tab:
If Not TabControl1.TabPages.Count = 1 Then
TabControl1.TabPages.RemoveAt(TabControl 1.SelectedIndex)
TabControl1.SelectTab(TabControl1.TabPag es.Count - 1)
int = int - 1
End If
Website Properties:
CType(TabControl1.SelectedTab.Controls.I tem(0), WebBrowser).ShowPropertiesDialog
Back:
CType(TabControl1.SelectedTab.Controls.I tem(0), WebBrowser).GoBack()
Forward:
CType(TabControl1.SelectedTab.Controls.I tem(0), WebBrowser).GoForward()
Refresh:
CType(TabControl1.SelectedTab.Controls.I tem(0), WebBrowser).Refresh()
Stop:
CType(TabControl1.SelectedTab.Controls.I tem(0), WebBrowser).Stop()
Home:
CType(TabControl1.SelectedTab.Controls.I tem(0), WebBrowser).GoHome()
Go:
CType(TabControl1.SelectedTab.Controls.I tem(0), WebBrowser).Navigate(ComboBox1.Text)
Timer1:
ToolStripStatusLabel1.Text = CType(TabControl1.SelectedTab.Controls.I tem(0), WebBrowser).StatusText
Комментарии