Results 1 to 8 of 8

Thread: Tabbed Browser Help

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Posts
    346

    Tabbed Browser Help

    I know people have asked this many times but i need some help. On howto create a new tab with code and how to delete it. I also asked this in an other thread but also how to make when you create a new tab it have a web browser in it? Thanks

    -Sherlockturtle

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Posts
    12,389

    Re: Tabbed Browser Help

    Add
    Code:
        Dim newTab As New TabPage
        Dim web As New WebBrowser
    right under your "Public Form1"
    This adds a new tab with a web browser in it:
    Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim lasttab As Integer = TabControl1.TabCount
            TabControl1.TabPages.Add(newTab)
            TabControl1.TabPages(lasttab).Controls.Add(web)
            newTab.Text = "This is a new tab"
            web.Dock = DockStyle.Fill
        End Sub
    This removes it
    Code:
    Dim lasttab As Integer = TabControl1.TabCount
            TabControl1.TabPages.Remove(newTab)
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | HtmlLessons | CssLessons | Code Tags | Sword of Fury - Jameram

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Posts
    346

    Re: Tabbed Browser Help

    Quote Originally Posted by dday9 View Post
    Add
    Code:
        Dim newTab As New TabPage
        Dim web As New WebBrowser
    right under your "Public Form1"
    This adds a new tab with a web browser in it:
    Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim lasttab As Integer = TabControl1.TabCount
            TabControl1.TabPages.Add(newTab)
            TabControl1.TabPages(lasttab).Controls.Add(web)
            newTab.Text = "This is a new tab"
            web.Dock = DockStyle.Fill
        End Sub
    This removes it
    Code:
    Dim lasttab As Integer = TabControl1.TabCount
            TabControl1.TabPages.Remove(newTab)
    Thank You

    Edit: Two question is there a way to call that tab "tab" plus what tab number it is(Plus one each time) and i would be creating multiple tabs is there a way i could still make it all work.
    I think i could do this by numbering each tab and taking that number and all the things on that page have that number in it. And search box could see what tab your on and add that number to all the things it does. Is there a way to see the current tab name? (Sorry if you dont understand i can try to refraze)
    Last edited by sherlockturtle; Dec 30th, 2011 at 05:35 PM.

  4. #4
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Posts
    12,389

    Re: Tabbed Browser Help

    To get the current tab's name, it would be something along the lines of

    Code:
    Dim tabName As String = TabControl1.SelectedTab.Name
            Console.WriteLine(tabName)
            'Doesn't have to be console.writeline
            'It could be label1.text = tabName or
            'TabControl1.SelectedTab.Text = tabName
    As for the other questions, I would like to see a little bit of work on your part. Try to get it done yourself, and then what ever errors you get post them here.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | HtmlLessons | CssLessons | Code Tags | Sword of Fury - Jameram

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Posts
    346

    Re: Tabbed Browser Help

    Ok.
    The code you just game me does not work i used this"Dim ct As String = TabControl1.SelectedTab.Text"(i used text and name) and it kept saying this was wrong.
    "Object reference not set to an instance of an object. "
    But i cant figure out which object is wrong because tabcontrol1 is the tab controls name.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Posts
    346

    Re: Tabbed Browser Help

    ive figured out what i was asking thanks.

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Tabbed Browser Help

    You might like to follow the CodeBank link in my signature and check out my Tabbed Web Browser thread. I never did get around to finishing it to the degree I intended but it demonstrates solutions to many of the basic problems.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2011
    Posts
    346

    Re: Tabbed Browser Help

    Quote Originally Posted by jmcilhinney View Post
    You might like to follow the CodeBank link in my signature and check out my Tabbed Web Browser thread. I never did get around to finishing it to the degree I intended but it demonstrates solutions to many of the basic problems.
    thanks
    Ive been using this to navigate and other things
    CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(ComboBox1.Text)
    but im only abel to get two tabs then when i create a third or fourth only the first one works. I can give more code if you need.
    Last edited by sherlockturtle; Dec 31st, 2011 at 11:19 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width