none
how to use a listbox as favs for a web browser and how to make tabs

    Question

  • how to use a listbox as favs for a web browser - my code is this
        Private Sub btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadd.Click
            ListBox1.Items.Add(TextBox1.Text)
        End Sub
        Private Sub Form1_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
            My.Settings.Save()
        End Sub

    how to make tabs - currently no code
    Wednesday, April 01, 2009 12:44 AM

Answers

  • Hi,

    Welcome to MSDN forums!

    1.    How to use ListBox as Favorites for your web browser?

    The key is by means of an object of System.Collections.Specialized.StringCollection type in My.Settings to persist in Favorites links.

    Step 1: Create a Windows Forms Application, then create a New Settings variable:
    Project menu-> Properties -> Settings ->create a setting as below
    Name   favList                           
    Type  
    System.Collections.Specialized.StringCollection   (Browser and locate this type)
    Scope    User         
    Value   (Add at least one item)


    Step 2:  Code sample
    Prerequisites: Drag&drop WebBrowser1, ListBox1, TextBox1 and Button1 onto Form1.

    Public Class Form1
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            TextBox1.Text = "Input URL here"
            WebBrowser1.Navigate("http://www.microsoft.com")
    
            ' Load Settings to ListBox when opening form
            For Each item As String In My.Settings.favList
                ListBox1.Items.Add(item.ToString)
            Next
        End Sub
    
        ' Add current WebBrowser URL
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim newURL As String = WebBrowser1.Url.ToString
            If ListBox1.Items.Contains(newURL) = False Then
                ListBox1.Items.Add(WebBrowser1.Url.ToString) 'add to ListBox1
                My.Settings.favList.Add(WebBrowser1.Url.ToString) 'add to My.Settings.favList
            End If
        End Sub
    
        'When press Enter key in TextBox, start to navigate
        Private Sub TextBox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
            If e.KeyCode = Keys.Enter Then
                WebBrowser1.Navigate(TextBox1.Text.Trim)
            End If
        End Sub
    
        ''When click/select item in ListBox, start to navigate too
        Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
            WebBrowser1.Navigate(ListBox1.SelectedItem.ToString)
        End Sub
    
        'Save Settings when closing form
        Private Sub Form1_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
            My.Settings.Save()
        End Sub
    
    End Class

    Here is the illustration:



    Also please check this thread for detail instruction: How to add Favorites/History feature to your web browser?
    http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/46729475-ffc5-4666-b4d0-f0d162a49acc


    2.
        How to add Tabbed feature to your web browser?
    Add your Web Bowser to a new TabPage object, then add the TabPage object to TabControl object.
    e.g.How to open new page in new tab window?

            Dim wb As New WebBrowser

            wb.Navigate("URL")

            Dim tab As New TabPage("Title")

            tab.Controls.Add(wb)

            TabControl.TabPages.Add(tab)

            TabControl.SelectedTab = tab

    Some tutorial about Tabbed web browser:
    http://social.msdn.microsoft.com/Forums/en/vbgeneral/thread/827d96b1-2868-4624-ad32-10917d87a9ed
    http://www.codeproject.com/KB/vb/TabPages.aspx



    Best regards,
    Martin Xie


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Thursday, April 02, 2009 1:34 PM

All replies

  • Hi,

    Welcome to MSDN forums!

    1.    How to use ListBox as Favorites for your web browser?

    The key is by means of an object of System.Collections.Specialized.StringCollection type in My.Settings to persist in Favorites links.

    Step 1: Create a Windows Forms Application, then create a New Settings variable:
    Project menu-> Properties -> Settings ->create a setting as below
    Name   favList                           
    Type  
    System.Collections.Specialized.StringCollection   (Browser and locate this type)
    Scope    User         
    Value   (Add at least one item)


    Step 2:  Code sample
    Prerequisites: Drag&drop WebBrowser1, ListBox1, TextBox1 and Button1 onto Form1.

    Public Class Form1
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            TextBox1.Text = "Input URL here"
            WebBrowser1.Navigate("http://www.microsoft.com")
    
            ' Load Settings to ListBox when opening form
            For Each item As String In My.Settings.favList
                ListBox1.Items.Add(item.ToString)
            Next
        End Sub
    
        ' Add current WebBrowser URL
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim newURL As String = WebBrowser1.Url.ToString
            If ListBox1.Items.Contains(newURL) = False Then
                ListBox1.Items.Add(WebBrowser1.Url.ToString) 'add to ListBox1
                My.Settings.favList.Add(WebBrowser1.Url.ToString) 'add to My.Settings.favList
            End If
        End Sub
    
        'When press Enter key in TextBox, start to navigate
        Private Sub TextBox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
            If e.KeyCode = Keys.Enter Then
                WebBrowser1.Navigate(TextBox1.Text.Trim)
            End If
        End Sub
    
        ''When click/select item in ListBox, start to navigate too
        Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
            WebBrowser1.Navigate(ListBox1.SelectedItem.ToString)
        End Sub
    
        'Save Settings when closing form
        Private Sub Form1_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
            My.Settings.Save()
        End Sub
    
    End Class

    Here is the illustration:



    Also please check this thread for detail instruction: How to add Favorites/History feature to your web browser?
    http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/46729475-ffc5-4666-b4d0-f0d162a49acc


    2.
        How to add Tabbed feature to your web browser?
    Add your Web Bowser to a new TabPage object, then add the TabPage object to TabControl object.
    e.g.How to open new page in new tab window?

            Dim wb As New WebBrowser

            wb.Navigate("URL")

            Dim tab As New TabPage("Title")

            tab.Controls.Add(wb)

            TabControl.TabPages.Add(tab)

            TabControl.SelectedTab = tab

    Some tutorial about Tabbed web browser:
    http://social.msdn.microsoft.com/Forums/en/vbgeneral/thread/827d96b1-2868-4624-ad32-10917d87a9ed
    http://www.codeproject.com/KB/vb/TabPages.aspx



    Best regards,
    Martin Xie


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Thursday, April 02, 2009 1:34 PM
  • thanks it will come in use also do you know how to do history or run each tab as a seperate progam
    Thursday, April 02, 2009 8:20 PM
  • Hi,

    1. How to store Web Browser History?
    The History and Bookmarks features of Web Browser actually are similar to Favorites feature, thus you still can implement it via My.Settings.
    Or you can try other suggstions in this thread:
    http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvb/thread/1c1ead9f-d688-49ff-b1e7-79da83931cd5

    2. How to open a new link in your own web browser instead of default web browser (e.g. Internet Explorer)?
    http://social.msdn.microsoft.com/Forums/en/vbgeneral/thread/d73dc0f7-d228-434c-877e-268562da52e7/


    Regards,
    Martin
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, April 06, 2009 6:38 AM
  • thanks
    Monday, April 06, 2009 11:26 AM
  • that works perfect thanks...
    Wednesday, January 06, 2010 11:23 PM
  • Hi,

    Welcome to MSDN forums!

    1.    How to use ListBox as Favorites for your web browser?

     

     

    The key is by means of an object of System.Collections.Specialized.StringCollection type in My.Settings to persist in Favorites links.

    Step 1: Create a Windows Forms Application, then create a New Settings variable:
    Project menu-> Properties -> Settings ->create a setting as below
    Name   favList                           
    Type  
    System.Collections.Specialized.StringCollection   (Browser and locate this type)
    Scope    User         
    Value   (Add at least one item)


    Step 2:  Code sample
    Prerequisites: Drag&drop WebBrowser1, ListBox1, TextBox1 and Button1 onto Form1.

    Public Class Form1
    
      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        TextBox1.Text = "Input URL here"
        WebBrowser1.Navigate("http://www.microsoft.com")
    
        ' Load Settings to ListBox when opening form
        For Each item As String In My.Settings.favList
          ListBox1.Items.Add(item.ToString)
        Next
      End Sub
    
      ' Add current WebBrowser URL
      Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim newURL As String = WebBrowser1.Url.ToString
        If ListBox1.Items.Contains(newURL) = False Then
          ListBox1.Items.Add(WebBrowser1.Url.ToString) 'add to ListBox1
          My.Settings.favList.Add(WebBrowser1.Url.ToString) 'add to My.Settings.favList
        End If
      End Sub
    
      'When press Enter key in TextBox, start to navigate
      Private Sub TextBox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
        If e.KeyCode = Keys.Enter Then
          WebBrowser1.Navigate(TextBox1.Text.Trim)
        End If
      End Sub
    
      ''When click/select item in ListBox, start to navigate too
      Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        WebBrowser1.Navigate(ListBox1.SelectedItem.ToString)
      End Sub
    
      'Save Settings when closing form
      Private Sub Form1_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
        My.Settings.Save()
      End Sub
    
    End Class
    

     

    Thanks, how do you remove selected items? i got it remove only with listview not in the actual settings.

    thanks,

    Saturday, February 26, 2011 6:59 AM
  • How would i use the TAG property and TEXT property of the list box class to make a favorites list box for a web browser?? im having difficulty doing this
    Thursday, August 30, 2012 7:16 PM