DimitarGraphics DimitarGraphics - 9 days ago 7
Vb.net Question

Issuse with tab names in vb.net browser

Well, i am creating a web browser in VB.NET... I know its stupid, but its true. My code is this:

Dim tab As New TabPage
Dim brws As New WebBrowser

Me.TabControl1.TabPages.Add(tab)
tab.Controls.Add(brws)
brws.Navigate("google.com")
tab.Text = brws.DocumentTitle
brws.Dock = DockStyle.Fill
Me.TabControl1.SelectedTab = tab


and as well i take a look at the C# question, but that didn't hel me. Also, the code is in
try
.
My problem is that when i open Google the title don't appear.

Line of the code:

tab.Text = brws.DocumentTitle


What's happening:

Image on Bulgarian images hosting

Also, please provide a code :) Thanks!

Dimitar

Answer

AddHandler can be used to subscribe to the DocumentCompleted event:

Dim tab As New TabPage, brws As New WebBrowser

AddHandler brws.DocumentCompleted, Sub() tab.Text = brws.DocumentTitle

Me.TabControl1.TabPages.Add(tab)
tab.Controls.Add(brws)
brws.Navigate("google.com")
brws.Dock = DockStyle.Fill
Me.TabControl1.SelectedTab = tab
Comments