OK, so I'm making this advanced web browser for myself that can do favorites. I'm using a combo box as an alternate text box, thinking this should do. But then, I ask myself, what code so I can open a new form, type a title, and put the url, so I can just click that specific thing when you click the arrow to go open the drop down list....

I'm not sure I'm clear so...

I was thinking on having them edit the cfg (configuration) files... but, I'm not sure that'll work, and I have no idea how to do that, or make the cfg file.

Here's an example of Home Page:

I want to set up my default page as something like...let's say Google. So what code and components do I use? Sorry, I'm like a total NOOB in VB....

Here's an example of the Favorites Problem:

I have my home page set up as Google. Now I want Facebook too. But I still want Google, so I go to my favorites and...What? I don't have a favorites! What do I do to make a favorites tab or whatever? Please give me the proper components and code (components are ex: buttons, textboxes, etc.)

Help is Greatly Appreciated!!


To create a history in a ComboBox, when navigating to a web site, add the url address to the ComboBox.
To save and load those items, check out this thread and replace the ListBox1 with your ComboBox.

For the HomePage, I would use a TextBox with a CheckBox. If the CheckBox is .Checked, then load the url address from your TextBox as your HomePage, otherwise, navigate to a blank page or the default HomePage preset by your app..

For Favorites, if your app. has a Favorites menu, add the Favorites to the selected menu option and save/load those.
If it does not have a menu, I would use a ListView to save the Favorites to, since you can add the web page's title as the item.Text and use the web page's url as the item.Tag to load the web page from.

commented: nice +1

Wow...That's very helpful!!! Thanks!!

Return "Glad that I could provide some insightful information to your thread.:)"

Wait... Actually, can you help me with one more thing? Can you explain the favorites more in-depth, I can't really cling onto what your talking about. Others I get though.... I don't know how to let the users just click something from the ComboBox and go to the website they added with


, but what comes after that? I also want to add the title. So it says something like:

"DANIWEB" and it goes to

http://www.daniweb.com in the browser.

Please Help!

See if this helps.
1 ComboBox, 1 WebBrowser

Public Class Form1
    Private arlComboBoxURLs As New ArrayList '// store url addresses.

    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        With WebBrowser1
            ComboBox1.Text = .DocumentTitle '// set .Text.
            If Not ComboBox1.Items.Contains(.DocumentTitle) Then '// do not add duplicates.
                arlComboBoxURLs.Add(.Url.AbsoluteUri) '// add url to ArrayList.
                ComboBox1.Items.Add(.DocumentTitle) '// add title to ComboBox.
            End If
        End With
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        '// since the ArrayList and ComboBox will have the same index for their titles and urls, use the .SelectedIndex to locate item in ArrayList.
        WebBrowser1.Navigate(arlComboBoxURLs(ComboBox1.SelectedIndex).ToString) '// navigate from ArrayList.
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        With WebBrowser1
            .ScriptErrorsSuppressed = True '// block script messages.
        End With
    End Sub
End Class


Inline Code Example Herghe

I have the bookmarks routine in my tabbed browser as well...
to add and remove bookmarks i add a new form containint:
- listbox1 (for the title)
- listbox2 (for the url)
- textbox1 (to assign a new title)
- button1 (to save the bookmark)
- button2 (to remove the bookmark)
2 environment variables: NomeLink (for the title) and Link (for the url)

notice that they are specialized string collection variables

Here is the code (it is for a tabbed browser but you can adjust it if you don't use tabs):

Public Class bookmarks

    Private Sub ListBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.Click
        ListBox2.SelectedIndex = ListBox1.SelectedIndex
    End Sub
    Private Sub ListBox2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox2.Click
        ListBox1.SelectedIndex = ListBox2.SelectedIndex
    End Sub

    Private Sub ListBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ListBox1.SelectedIndexChanged

        Dim wb As CustomTabbedBrowser = browser.TabControl1.SelectedTab.Tag
    End Sub

    Private Sub ListBox2_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ListBox2.SelectedIndexChanged
        Dim wb As CustomTabbedBrowser = browser.TabControl1.SelectedTab.Tag
    End Sub

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        If TextBox1.Text <> Nothing Then
            Dim wb As CustomTabbedBrowser = browser.TabControl1.SelectedTab.Tag
            MsgBox("Insert a page title for the URL")

        End If
    End Sub

    Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
            Dim item As Integer = My.Settings.Link.IndexOf(ListBox2.SelectedItem)
            Dim nome As Integer = My.Settings.NomeLink.IndexOf(ListBox1.SelectedItem)
        Catch ex As Exception

        End Try

    End Sub

    Private Sub TextBox1_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox1.TextChanged

        Dim title As String = TextBox1.Text
    End Sub

    Private Sub bookmarks_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        For Each item In My.Settings.Link
        For Each nome In My.Settings.NomeLink
    End Sub
End Class

Hope it helps...

As for the Homepage, you can add a button to your browser, something like: 'set url to homepage'.
This will catch the URL you are navigating at the moment and will store it in an environment variable named HomePage.

something like this

Private Sub ButtonSaveHome_Click(sender As System.Object, e As System.EventArgs) Handles ButtonSaveHome.Click

        My.Settings.HomePage = webbrowser1.url.tostring 'change it to your browser control name
End Sub

then you can use the browser Load event to recall the HomePage or also a 'Go to Home' button with the proper code. You should foresee the possibility that the homepage variable has not been set yet, and so you must redirect to a page of your choice to avoid errors:

if my.settings.homepage <> "" then
webbrowser1.navigate (my.settings.homepage)
end if