# VBForums CodeBank > CodeBank - Visual Basic .NET >  Tabbed WebBrowser - a work in progress

## jmcilhinney

Lots of people have asked lots of questions relating to building a tabbed Web browser.  I've seen the same questions asked again and again so, rather than answering them again and again, I'm going to build a tabbed Web browser, piece by piece, and post the result here.

The first stage is the WebBrowser controls on the TabPages.  It's usually beginners but I've answered the question of how to put multiple WebBrowser controls on multiple TabPages too many times already.  One of the basic ideas of OOP is encapsulation.  Another is inheritance.  Let's put those together to inherit the TabPage control to encapsulate a WebBrowser control.
VB.NET Code:
Public Class WebBrowserTabPage
    Inherits System.Windows.Forms.TabPage
     Private _browser As New WebBrowser
     Public ReadOnly Property Browser() As WebBrowser
        Get
            Return Me._browser
        End Get
    End Property
     Public Sub New()
        Me._browser.Dock = DockStyle.Fill
        Me.Controls.Add(Me._browser)
    End Sub
 End Class
Now, instead of adding regular TabPages to your TabControl you create WebBrowserTabPage objects and add them.  Each one IS a TabPage so it can be added to a TabControl, and each one creates and displays it's own WebBrowser control.

I've added a ReadOnly property via which you can access the WebBrowser control from the TabPage.  This allows you to access properties, methods and events of the WebBrowser from outside the TabPage.  If you wanted to be "more correct" you could keep the WebBrowser private and declare pass-through members in the WebBrowserTabPage class, e.g.
VB.NET Code:
Public Sub Navigate(ByVal urlString As String)
    Me._browser.Navigate(urlString)
End Sub
That would be considerably more work though, as the WebBrowser class has quite a few members.

Stay tuned for additions and improvements but, for now, it's a start.  :Smilie:

----------


## jmcilhinney

Here's the first update.  It's a couple of improvements to the WebBrowserTabPage class.
vb.net Code:
Public Class WebBrowserTabPage    Inherits System.Windows.Forms.TabPage     Private WithEvents _browser As WebBrowser     Public ReadOnly Property Browser() As WebBrowser        Get            Return Me._browser        End Get    End Property     Public Sub New()        Me.New(New WebBrowser)    End Sub     Public Sub New(ByVal browser As WebBrowser)        browser.Dock = DockStyle.Fill        Me.Controls.Add(browser)        Me._browser = browser         If browser.DocumentTitle = String.Empty Then            Me.Text = "(Empty)"        Else            Me.Text = browser.DocumentTitle        End If    End Sub     Private Sub _browser_DocumentTitleChanged(ByVal sender As Object, _                                              ByVal e As EventArgs) Handles _browser.DocumentTitleChanged        Me.Text = Me.Browser.DocumentTitle    End Sub End Class
Firstly the _browser variable has been declared WithEvents.  I've then handled its DocumentTitleChanged event so the the page title is displayed automatically on the tab.

I've also changed the constructor a bit and added another.  This allows you to create a page with an existing WebBrowser control.  The reason for this will become clear at a later stage.

----------


## vbleet

Thanks for this, it is very helpful!

----------


## jmcilhinney

The next instalment is here.  It's nothing too exciting.  I've added some pass-through members to the WebBrowserTabPage class for what I consider to be the most important members of the WebBrowser class.  By "pass-through members" I mean public members whose only purpose is to provide access to the corresponding member of the internal WebBrowser control.  For instance, the WebBrowserTabPage.IsBusy property simply returns the value of the WebBrowser.IsBusy property.  This just makes things a bit cleaner because we can access members of the tab page instead of having to access a member of its Browser property.  The Browser property is still there in case we need to access other members though.

This is pretty much it for the WebBrowserTabPage.  The next step will be to customise the TabControl a little to get easier access to WebBrowserTabpage objects, rather than casting TabPage references all the time.  After that it will be time to create a UserControl that incorporates the customised TabControl but also lets us hide the tabs when there is only one page open, which many browsers do.  Beyond that it will be time to put that control on a form and start implementing some real Web browser functionality.

----------


## jmcilhinney

Back again with another addition.  As I said it would be, this is not especially exciting but it is useful.  It's a customised TabControl will return the SelectedTab or any tab page by index as a WebBrwoserTabPage reference.  That saves you having to cast from type TabPage to type WebBrowserTabPage yourself every time you want to reference a page.

Note that this control will be beefed up later on, with the addition of things like context menus on each tab and a close button on each tab too.  That's advanced functionality though, so let's get the basics in place first.

The next installment will be the promised UserControl, which will be a bit more interesting.  After that there will be a form involved, so we will start to see some of this functionality in action.  Initially the form will have an address bar, a Go button and Back and Forward buttons.

----------


## gameguru345

Could i get a full project of this?

----------


## jmcilhinney

> Could i get a full project of this?


I will be attaching the project to each post as I go as soon as there's a project worth posting.  That will be when there's more than just my own code involved.  That will be as soon as I create a user control or a form.  That will be the next stage.

----------


## gameguru345

thank you, but please hurry, i have limited time to get the tabs. (homework project)

----------


## jmcilhinney

> thank you, but please hurry, i have limited time to get the tabs. (homework project)


Yes, let me hurry to do this on my own time so you don't have to do your own homework.

----------


## gameguru345

soz, cant you just send a full project of your last one. it would make things easier

and no your not doing it for me its a feature i want to have in my own project.

----------


## dead-man

I have a small problem when i add the first tab it works great when i add others all the web browser controls disapear am i doing some thing wrong

----------


## jmcilhinney

> I have a small problem when i add the first tab it works great when i add others all the web browser controls disapear am i doing some thing wrong


Yes you are.

----------


## jmcilhinney

To those who were following this thread, I apologise for letting it go stale.  I have been looking for a job and a place to live in recent weeks.  I've been spending most of my free time improving my ASP.NET skills.  I start a new job in a week and once I'm settled in I'll get back to this project.

----------


## JuggaloBrotha

> To those who were following this thread, I apologise for letting it go stale.  I have been looking for a job and a place to live in recent weeks.  I've been spending most of my free time improving my ASP.NET skills.  I start a new job in a week and once I'm settled in I'll get back to this project.


You going to be alright?  At least where you live the economy's not f**ked (unlike where I live - Michigan, USA)

----------


## jmcilhinney

Hey! I'm finally back to this project.  I have attached the most recent version of the project to the first post in this thread.  I'll do the same each time I make changes.

Note that the code is well commented so make sure you read it carefully before posting any questions.

At the moment you can add and close tabs and the application will react appropriately to changes in the selected tab. This means that the window title, the address and the status text and progress will update for the currently selected tab.

The Back, Forward, Refresh, Stop and Open commands don't work at the moment.  Working versions of these will be the next addition to the project.  After that I'll look at adding functionality like favourites and history, as well as addressing issues like what happens when a new window wants to open.

Questions and suggestions are welcome but I make no guarantees about if or when I'll be able to address them.

----------


## Orkidea

Great news  :Smilie:  Looking forward for uptades

----------


## jmcilhinney

I've added another update to the project.  The Back and Forward buttons and menu items now work.  I've also added a Home button and menu item and an Options dialogue where you can set the home page.  There are a few other little superficial changes that I won't go into.  The new version has replaced the old version attached to the first post.

Note that the home page feature demonstrates the use of My.Settings for those who aren't familiar with it.  I chose not to bind the controls in the Options dialogue to the settings to allow the user to make changes and then cancel without saving.

----------


## dom_stapleton

It might be superfluous but you could make the default page for each new tab "about**:Tabs". Then it shows the "new tab opened" page from Internet Explorer.

Otherwise, a brilliant little application! You could always try and write your own web browser too if you had the patience!

----------


## Lord Orwell

if you do incorporate anything, make the home page configurable.  That annoying home page is one of the reasons i quit using IE.  Besides which, even that page itself has a setting to stop you ever seeing it again.  then it automatically opens about**:blank.

----------


## Xancholy

jmc, excellent work on this project.

Please can you show me how to capture the url of the currently selected tab within tabbedwebbrowser ?

----------


## jmcilhinney

> jmc, excellent work on this project.
> 
> Please can you show me how to capture the url of the currently selected tab within tabbedwebbrowser ?


The current project already does that, when a page loads or when you switch tabs.

----------


## Xancholy

Thanks. I see what you mean. Selected tab's url is displayed in addressbar.

----------


## jmcilhinney

> Thanks. I see what you mean. Selected tab's url is displayed in addressbar.


Uhuh.  Look first, ask questions later.

----------


## Referee2424

When user selects any tab, how can I find the tab name and refer to that tab in code ? Thank you

----------


## Lord Orwell

> When user selects any tab, how can I find the tab name and refer to that tab in code ? Thank you


did you happen to read his other posts?  Read #5 again.

----------


## Referee2424

> It's a customised TabControl will return the SelectedTab or any tab page by index as a WebBrwoserTabPage reference.


Thanks> I'm sorry I'm just learning. Please can you show me how to refer to selectedtab by code ?

----------


## jmcilhinney

> Thanks> I'm sorry I'm just learning. Please can you show me how to refer to selectedtab by code ?


No.  Download the project.  Open it.  Read the code.

----------


## Referee2424

No ? I had downloaded it, opened it and read the code. OK, then, people seem to be rude on these forums.

----------


## Xancholy

```
Warning	1	XML comment has a tag with a 'cref' attribute 'OptionsDialogue' that could not be resolved. XML comment will be ignored.	TabbedWeBrowserOptionsDialogue.vb	18	39	Tabbed Web Browser
```

Anyone else getting this error ? Also main form line 22/39 same xml 'cref' error.

Code compiles and builds fine though... Just thought I'd check.

----------


## jmcilhinney

> No ? I had downloaded it, opened it and read the code. OK, then, people seem to be rude on these forums.


Maybe people think that when they spend hours creating a sample program for the benefit of others that those others shouldn't really need to ask a questions that are clearly answered in that sample program.  Have you searched that code for SelectedTab to see how I've used it?  If you have a separate question that doesn't relate to my code specifically then this thread is not the place to post it.

----------


## jmcilhinney

> ```
> Warning	1	XML comment has a tag with a 'cref' attribute 'OptionsDialogue' that could not be resolved. XML comment will be ignored.	TabbedWeBrowserOptionsDialogue.vb	18	39	Tabbed Web Browser
> ```
> 
> Anyone else getting this error ? Also main form line 22/39 same xml 'cref' error.
> 
> Code compiles and builds fine though... Just thought I'd check.


That's a warning, not an error, and it doesn't exist in my code.  You have presumably changed the name of the OptionsDialogue class to TabbedWeBrowserOptionsDialogue and failed to change the reference to the original class name in the XML documentation comments.  Just double-click the warning message in the Error List window and it will take you to the offending line, which you can then edit.  You might also like to consider spelling the name of your class correctly.  It should be "TabbedWe*b*BrowserOptionsDialogue".

That said, how many Options dialogues are you going to have in the Tabbed Web Browser project that you need to change the name like that anyway?  Isn't it fairly obvious that an OptionsDialogue class in a Tabbed Web Browser project is a dialogue for the options for the app without changing the name?  What's the point of really long names if they don't actually add any clarity?

----------


## epixelman

Nice job jmc on the tabbed browser.

What other plans do you have for this?
What's next?

 :Smilie:

----------


## jmcilhinney

> Nice job jmc on the tabbed browser.
> 
> What other plans do you have for this?
> What's next?


Bookmarks, history and then some tab-specific features like a right-click menu.

----------


## Miha2c30

Jmc, if it's possible, how can I add your WebBrowserTabControl component to my toolbox? I already added files to my project, but WebBrowserTabControl component is still missing...

Edit: Nevermind, I found a video tutorial on youtube :Big Grin:

----------


## formlesstree4

yay for youtube :P

Anyway, on topic reply: Great job here  :Wink: , I would ask for permission to use this project as a basis for a big thing I'm doing, but, I'll use it as a reference, cause it is well commented as he has said.

Props to you my friend  :Big Grin:

----------


## jmcilhinney

> yay for youtube :P
> 
> Anyway, on topic reply: Great job here , I would ask for permission to use this project as a basis for a big thing I'm doing, but, I'll use it as a reference, cause it is well commented as he has said.
> 
> Props to you my friend


Anything I post on this forum is intended to be free to access and use under any conditions by anyone, unless otherwise stated.  I do appreciate your asking though.

----------


## formlesstree4

Oh ok then, well, I'll still be sure to give you credits in the about page  :Big Grin:

----------


## penagate

I have removed some posts from this thread.  If you have any comments concerning other members then you are welcome to state them directly in a private message and not in the public forums.  Please keep this this thread to comments and discussion concerning this codebank submisssion ONLY.

----------


## Ajx123

No this doesn't help to download files from FTP server

----------


## scootabug

Hey JMC, how's this project coming along?  You haven't been asked since 25-Aug-08...thought it'd be time to annoy you again!  ;-)

----------


## SLackey

hey JMC Just wanted to say nice work I learned alot about vb.net looking through this project... 
So I just wanted to say thanks...

----------


## NickThissen

I just noticed your comment on my custom TabControl Codebank submission. Thanks for that! I would be pleased to see "my" context-menu TabPages in this project!

Still, I'm not sure if my project is of much help for this. My aim was to be able to specify a different ContextMenu of your own choice to every TabPage, so you would not be limited to having the same ContextMenu on each TabPage. However, I can't see much use for different ContextMenu's in a webbrowser, they would probably be the same everywhere, in which case it would be much easier to handle the ContextMenu displaying differently (for one, you would not need to create a Designer class...).

My Tabbed MDI Editor codebank submission uses a much easier way to display a ContextMenu (one ContextMenu per TabControl, not separate per TabPage) by simply setting the TabControl's ContextMenu property, and checking for the SelectedTab in the ContextMenu_Opening event.

----------


## Lord Orwell

i am interested in the owner-drawn close buttons promised.  I've managed to get something like this to work in a project i am working on, but i am unsure of the best way to go about it.  I would like the "hot" effect when it's moused over (a giant close button for a media center program) but i have been unable to actually find anything besides the standard button in the owner-draw.

----------


## jmcilhinney

I've been concentrating on C# code examples for a while but I will get back to this.

----------


## austinjf785

um... where do I put the code?

I am new 2 VB.... just started 2day  :Smilie:

----------


## austinjf785

> um... where do I put the code?
> 
> I am new 2 VB.... just started 2day


k,  I think I know where to put it... but....

Nothing is happening.

----------


## NickThissen

> k,  I think I know where to put it... but....
> 
> Nothing is happening.


You don't put the code anywhere, it is a complete project you can open and run. If you want to incorporate it into your own project, I think the meaning of this example is that you read it, try to understand what it does, and then recreate it in your own project. Once you understand how the code works you will have little trouble recreating it (especially if you keep a second instance of Visual Studio running alongside so you can peek sometimes, that's what I do!).

Also, "nothing is happening" means nothing, you need to be more specific. I also don't think this thread is supposed to be for basic questions on this example.

----------


## austinjf785

> You don't put the code anywhere, it is a complete project you can open and run. If you want to incorporate it into your own project, I think the meaning of this example is that you read it, try to understand what it does, and then recreate it in your own project. Once you understand how the code works you will have little trouble recreating it (especially if you keep a second instance of Visual Studio running alongside so you can peek sometimes, that's what I do!).
> 
> Also, "nothing is happening" means nothing, you need to be more specific. I also don't think this thread is supposed to be for basic questions on this example.


Oh, okay

NO COMMENT on the rest of it

----------


## Lord Orwell

it is acceptable to ask question about the project in the thread, but if you stray too far off topic you are risking sanctions from the moderators and a deletion of your posts.  See page 1.

----------


## pillhead2007

i want to know how to make the tabs document change to the url which the combobox navigates too and how to change the tabs respond commands like ie8 as in if i click a tab it selects it how to add a close button to the tab like ie8  and how to make add events for url to display in the bottom left hand corner like IE8 look at the pic below i want to embed this into my Web Browser please any1 Help Me

----------


## Miha2c30

How can I add those components to my project's toolbox?  :Confused:

----------


## jmcilhinney

> How can I add those components to my project's toolbox?


This doesn't really have anything to do with the topic of this thread specifically.  Adding items to the Toolbox is the same no matter what they are.

When you declare components in a solution they will automatically become available in the Toolbox within that solution after you build.  If you want to add a component to the Toolbox permanently then you need to declare in a project that compiles to a DLL, i.e. a Class Library or Windows Control Library project.  You can then add the component(s) in that DLL to the Toolbox the same way as any other DLL: by right-clicking the Toolbox or from the main menu.

----------


## nzwogboy

Is this suppose to be able to work in Visual Basic Express 2008? I imported it but got errors, I have access to the code etc but when I debug it gives errors. Anyway I probably shouldn't need to run just find the code I am looking for, I have had a look through and have not been able to see how you handle popups/new windows being launched from a hyperlink. That is why I wanted to run the program so I could see if new windows opened up in new a tab, if so then I could look through the code to find out where you handle it. So as I can't run it, I will assume that a new window will open in a new tab and if this is the case, where should I be looking in the code for this. I can't seem to find newwindow anywhere. Could someone please point me in the right direction?

----------


## jmcilhinney

> Is this suppose to be able to work in Visual Basic Express 2008? I imported it but got errors, I have access to the code etc but when I debug it gives errors. Anyway I probably shouldn't need to run just find the code I am looking for, I have had a look through and have not been able to see how you handle popups/new windows being launched from a hyperlink. That is why I wanted to run the program so I could see if new windows opened up in new a tab, if so then I could look through the code to find out where you handle it. So as I can't run it, I will assume that a new window will open in a new tab and if this is the case, where should I be looking in the code for this. I can't seem to find newwindow anywhere. Could someone please point me in the right direction?


Several people have said that they get errors but noone yet has told me what the errors are so I simply can't help.  I've downloaded my own attachment and successfully opened it in VS 2005 and VS 2008.  I haven't tried VB Express as I no longer have it installed.

I haven't got as far as handling popups yet so I'm afraid I can't help you there, although there have definitely been posts on the topic in the VB.NET forum.

----------


## nzwogboy

Thanks anyway. The error I get is the 

```
Me.tabs.AddTab()
```

it says "NullReference Exception was unhandled" "Object reference not set to an instance of an object."

----------


## bl34ch127

Im getting the same error as nzwogboy.

It throws an exception at runtime

----------


## pillhead2007

TabControl.TabPages.Add(X) 

my example is add tabcontrol name it tabcontrol in properties in design name and called tabpage1 as tabpage in design name on properties

----------


## bl34ch127

> TabControl.TabPages.Add(X) 
> 
> my example is add tabcontrol name it tabcontrol in properties in design name and called tabpage1 as tabpage in design name on properties


I dont really know what you just said. :[

----------


## pillhead2007

basically create new form add tabcontrol from toolbox then set its properties (design Name)should be default called tabcontrol1 call it TabControl .... then click the white window underneath go to its properties and should be called by default TabPage1 call it Tabpage ...... then go to toolbox add web browser and go to its properties should be called by default WebBrowser1 call it WebBrowser Then Add A Button  double Click that Button And Add this code to that button code  

On Error Resume Next
        Dim X As New TabPage
        X.Text = Me.ActiveBrowser.DocumentTitle
        TabControl.TabPages.Add(X)
        Dim Y As New WebBrowser
        Y.Dock = DockStyle.Fill
        X.Controls.Add(Y)

----------


## Lord Orwell

ignoring errors?

----------


## bl34ch127

Ah ok I figured it out.

When it loaded up it didnt have a control called 'tabs' so I just added one and it worked.. Thats what you were getting at right?

Thanks guys for the help  :Smilie:

----------


## pillhead2007

its just incase the webbrowser doesnt naviagete or network unavailble  due to your coding so there for the tabs will just ignore these errors and add tab

----------


## pillhead2007

yeap i was no problem matey

----------


## snakegaer

there are some links that if we click on will open a new window on the internet explorer is it posible to make them open in a new tab?

----------


## snakegaer

i used this code to cancel links to open in new windows (IE) but what should i write where X to open the link i clicked on in a new tab?



```
    Private Sub currentBrowser_NewWindow(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles currentBrowser.NewWindow
        e.Cancel = True
        Me.tabs.AddTab(X)

    End Sub
```

X is the url string

----------


## jmcilhinney

> there are some links that if we click on will open a new window on the internet explorer is it posible to make them open in a new tab?


That's a feature I haven't got around to tackling yet.  I'm fairly sure that other people have posted questions and answers on the same topic in the VB.NET forum, but I have no specific links I'm afraid.

----------


## Reece Benson

Hey there, it looks like you're getting on well with this sample project. I'm a young learner in programming, (really young... you'll be surprised). I've been learning quite alot about Visual Basic '08 and I have been learning for about 6 months now. I've been making alot of tabbed web browsers, and history and bookmarks.

I've made quite alot of login systems, and notepads etc (the basic microsoft programs). I've always wanted to know how to make either the link clicked in the browser open either in a new tab or in a new window. I can make the code, just I can't find the Handles to use with it.

Have you got any ideas with this JMC?
All the best,
*Reece Benson*

----------


## jmcilhinney

> Hey there, it looks like you're getting on well with this sample project. I'm a young learner in programming, (really young... you'll be surprised). I've been learning quite alot about Visual Basic '08 and I have been learning for about 6 months now. I've been making alot of tabbed web browsers, and history and bookmarks.
> 
> I've made quite alot of login systems, and notepads etc (the basic microsoft programs). I've always wanted to know how to make either the link clicked in the browser open either in a new tab or in a new window. I can make the code, just I can't find the Handles to use with it.
> 
> Have you got any ideas with this JMC?
> All the best,
> *Reece Benson*


As I said previously, that's a problem I haven't tackled yet.  I think it can be a bit tricky with the .NET WebBrowser control because it lacks one or two members exposed by the old ActiveX document viewer control.  The WebBrowser control does have an ActiveXInstance property but I haven't worked out how to use that yet.

----------


## Lord Orwell

even in ie it doesnt do it automatically.  i had this working in mine but used the com object.  if i remember correctly i was cancelling navigation which stopped the new window then browsing to the blocked link in the new tab

----------


## gep13

Hey,

If anyone is interested, I have created a C# version of the latest version of the VB.Net Tabbed Web Browser.  You can find it here:

http://www.vbforums.com/showthread.p...44#post3769244

It is a direct copy of the current functionality of the Tabbed Web Browser (or at least I think it is  :Smilie: )

Gary

----------


## supernix

I wanted to do a browser so bad I had no idea that this is a project that gets done to death. Great post anyway.

----------


## Haza360

I am using vb 2008 express and I downloaded this project but various parts seem to be missing, and I get these warnings: 

Could not find type 'TabbedWebBrowser.WebBrowserTabControl'.  Please make sure that the assembly that contains this type is referenced.  If this type is a part of your development project, make sure that the project has been successfully built.
*and*
The variable 'tabs' is either undeclared or was never assigned.	

And this exception at runtime:
*NullReferenceException was unhandled*
Object reference not set to an instance of an object.
Please help!!!  :Confused:   :Frown:

----------


## gep13

Hey,

Am I right in saying that you get this error in the IDE when you try and open the MainWindow Form in design mode?

Can you take a screen shot of what you are seeing?

Gary

----------


## Haza360

Opening the MainWindow Form in design mode works fine (although it does look a bit wierd). Here it is:


The exception however is when I debug it:

Does this help?

----------


## gep13

Hey,

When you opened the project in 2008 Express, did it go through a conversion process?  If so, were there any errors?  Did you change any of the code once you downloaded it?

The screen shot that you have shown suggests that the WebBrowserTabControl is not being found, and placed on the form surface.  That is why you are getting the null reference exception.

Gary

----------


## Haza360

> Hey,
> 
> When you opened the project in 2008 Express, did it go through a conversion process?  If so, were there any errors?  Did you change any of the code once you downloaded it?
> 
> The screen shot that you have shown suggests that the WebBrowserTabControl is not being found, and placed on the form surface.  That is why you are getting the null reference exception.
> 
> Gary


Yes, I converted it but there were no errors.
I have not edited any of the code.

----------


## gep13

Hey,

As a test, I have just downloaded the source code again from the original post, and opened it up in Visual Studio 2008 Team Edition, and it worked perfectly.  I am just installing Visual Basic 2008 and I am going to do the same test.

Will post back once it is installed.

Gary

----------


## Haza360

By 


> Visual Studio 2008 Team Edition


 do you mean Visual Studio 2008 Express Edition, or an edition you payed for?

----------


## gep13

Hey,

This is a higher version of Visual Studio that I get through my MSDN Subscription.  It isn't free.

I have just tested the download through VB 2008 Express, and it works, so I am not sure what is going on here.  Is it possible that you can zip up the folder containing the code that you are trying to run, and post it here?

Gary

----------


## gep13

Out of curiousity, can you try the download here:

http://www.vbforums.com/showthread.p...42#post3769342

This is a project which extends the work done by jmcilhinney.  The one difference is that it was created in Visual Studio 2008, where as this project was created in Visual Studio 2005.  There really shouldn't be any difference, but it would be interesting to see if it works for you or not.

Gary

----------


## gep13

Hey,

Let's back up a step here...

Looks like I spoke to soon when I said that is was working fine within Visual Basic 2008 Express Edition.  I have just done the conversion again, and looks like I have got the same problem as you.  For some reason, something has gone wrong with the conversion.

Follow these steps to get it working.

1) Open the MainWindow.Designer.vb file
2) Search for the word "tabs" in this document (you should only find one reference)
3) Delete the entire line that the word tabs is in, i.e. "Private WithEvents tabs As TabbedWebBrowser.WebBrowserTabControl"
4) Go to design view, and drag a "WebBrowserTabControl" onto the form surface and set the following propreties:
 - Name - tabs
 - Dock - Fill
 - TabPages - Delete all existing tabs

And that should be you back in business.

Hope that helps!!

Gary

----------


## Haza360

Thanks so much for your help Gep13.
In the end I got it working by re-downloading the source and re-converting it.
Its obviously very temperamental in vb express editions.
The only thing now is that, i've edited some of it into my own vb.net web browser and I get the following errors:

'AddTab' is not a member of 'System.Windows.Forms.TabControl'.
'SelectedWebBrowser' is not a member of 'System.Windows.Forms.TabControl'.
'SelectedWebBrowser' is not a member of 'System.Windows.Forms.TabControl'.
'SelectedWebBrowserTabPage' is not a member of 'System.Windows.Forms.TabControl'.
'PerformClick' is not a member of 'System.Windows.Forms.PictureBox'.
'PerformClick' is not a member of 'System.Windows.Forms.PictureBox'.
'PerformClick' is not a member of 'System.Windows.Forms.PictureBox'.
'PerformClick' is not a member of 'System.Windows.Forms.PictureBox'.
'PerformClick' is not a member of 'System.Windows.Forms.PictureBox'.
'PerformClick' is not a member of 'System.Windows.Forms.PictureBox'.
'SelectedWebBrowser' is not a member of 'System.Windows.Forms.TabControl'.

Do you know how I could fix these errors?
Thanks again Gep13!

----------


## gep13

Hey,

Without knowing about exactly what source you are referring to, and what changes you are making, it is difficult to say.

Having said that, the first four that you mention are related to the additional methods that jmcilhinney added to a class, WebBrowserTabControl, that inherits from TabControl.  From the look of it, you are not using this inherited class, but rather the standard TabControl.  Is that correct?

Also, do a search for PerformClick in your code, are you attempting to access a member called PerformClick on a PictureBox, if so, this is not going to work.

Gary

----------


## Haza360

> Hey,
> 
> Without knowing about exactly what source you are referring to, and what changes you are making, it is difficult to say.
> 
> Having said that, the first four that you mention are related to the additional methods that jmcilhinney added to a class, WebBrowserTabControl, that inherits from TabControl.  From the look of it, you are not using this inherited class, but rather the standard TabControl.  Is that correct?
> 
> Also, do a search for PerformClick in your code, are you attempting to access a member called PerformClick on a PictureBox, if so, this is not going to work.
> 
> Gary


Silly me! Is there an equivalent of PerformClick that I can use for a picture box?

----------


## gep13

Hey,

There isn't an equivalent.

What you should do is the following...

1) Take the code that is currently in the PictureBox's Click event and create a new method that does all that work
2) Call this method from within the Click Event
3) Call this method from the other place that you want to call PerformClick

Hope that makes sense.

Gary

----------


## Haza360

Thanks, that should help.

----------


## Haza360

On the tabbed web browser project's main window there is a tab control called tabs. In the properties section of this control there are two properties called: SelectedWebBrowser and SelectedWebBrowserTabPage. These properties aren't on normal tab controls. How did the tab control get these properties, and if I get them on my tab control, could it fix some of my errors?

----------


## gep13

Hey,

As I mentioned in a previous post, jmcilhinney extended the regular TabControl and created the WebBrowserTabControl.  Into this, he added the members that you mention.  In order to have these, you would also need to create your own control, and have it inherit from TabControl.

The tabs control is an instance of the WebBrowserTabControl class, not TabControl.

Gary

----------


## Haza360

> Hey,
> 
> As I mentioned in a previous post, jmcilhinney extended the regular TabControl and created the WebBrowserTabControl.  Into this, he added the members that you mention.  In order to have these, you would also need to create your own control, and have it inherit from TabControl.
> 
> The tabs control is an instance of the WebBrowserTabControl class, not TabControl.
> 
> Gary


Thanks again Gep13!

----------


## gep13

Hey,

Does that mean you have got it to work?

Gary

----------


## dewshare

Hi 

I have consult this code, but problem of Progress Bar for Each tab is still there please can you extend you tutorial and handle this problem . I shall be thank full to you

----------


## jmcilhinney

> Hi 
> 
> I have consult this code, but problem of Progress Bar for Each tab is still there please can you extend you tutorial and handle this problem . I shall be thank full to you


You need to look a bit harder because this project already does handle progress.  It displays a progress bar in the status bar at the bottom if and when the current tab is downloading.  As you switch between tabs the progress bar is displayed, hidden or updated to reflect the new current tab.

----------


## dewshare

can you help me to do same in vb 2008 your code is in 2005 most of commands not runs. Please .....

----------


## jmcilhinney

> can you help me to do same in vb 2008 your code is in 2005 most of commands not runs. Please .....


Not true.  VB 2008 adds some things that won't work in VB 2005 but everything that already existed in VB 2005 still exists and works exactly the same way in VB 2008.  I've opened this very project myself in VS 2008 and it upgraded and ran without issue.  I haven't tried in VB Express 2008 but I would expect that to do the same.  If you're having some specific issue then you need to address that specific issue.  Even if you have to create a new project, all the classes and code could be added directly and it would work.

----------


## MrTree

I seem to be having a problem of putting the WebBrowserTabControl component in the toolbox, ive tried compiling the WebBrowserTabControl.vb and WebBrowserTabPage.vb on their own, to make a dll file, then add it to the toolbox it wont let me, ive even tried draggin the WebBrowserTabControl to the form, it only shows a circle with a line in the middle meaning im not allowed.

Any help apprecieated, ive probably missed something.

I forgot to mention im using Visual Studio 2008 Pro

----------


## cancelor

Tabbed WebBrowser working fine, but now I want to use use the WebBrowserDocumentCompletedEvent, I have :-



```
Private Sub _browser_DocumentCompleted(ByVal sender As Object,_
 ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) _
Handles _browser.DocumentCompleted

        MsgBox("doc complete")

    End Sub
```

but it never gets called. ... any one got any ideas?

----------


## cancelor

Solution found here:-

http://www.vbforums.com/showthread.php?t=641086

many thanks to Decimate.

----------


## coolcurrent4u

@jmcilhinney

Which code has your latest update

----------


## jmcilhinney

> @jmcilhinney
> 
> Which code has your latest update


If I make changes, I always update the original attachment.

----------


## asdatapel

Hi jmcilhinney.
I'm making my own tabbed browser and its similar to yours. I've gotten pretty far and I need some help. I want to make it so that a middle click on a link would open up a new tab. I don't know how to make that event happen. Is it impossible because the browsers are made on the fly?

----------


## gep13

Hello,

The MouseDown event:

http://msdn.microsoft.com/en-us/libr...mousedown.aspx

You can look at the input event args to determine which button was clicked.  You can find an example here:

http://www.vbdotnetheaven.com/Upload...useEvents.aspx

Gary

----------

