FAQ: How do I add Favorites/Bookmark features and Tabbed feature to my own web browser?
Locked
-
Saturday, April 11, 2009 11:34 AM
How do I add Favorites/Bookmark features and Tabbed feature to my own web browser?
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.
All Replies
-
Saturday, April 11, 2009 11:36 AM
1) To add Favorites/Bookmark features to your own web browser, you can use My.Settings (Choose System.Collections.Specialized.StringCollection data type) to persist/store all items of Favorites or Bookmark.
For example: Implement the Favorites feature for your web browser.
Firstly create a New Settings variable:
Project -> Properties -> Settings ->create a setting as below
Name favList
Type System.Collections.Specialized.StringCollection (Browser and locate this type)
Scope User
Value (Set several initial items)
Prerequisites: Drag&drop MenuStrip1 (with ToolStripMenuItem1 and ToolStripMenuItem2) and WebBrowser1 onto Form1.s
Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load ToolStripMenuItem1.Text = "Favorites" ToolStripMenuItem2.Text = "Add" WebBrowser1.Navigate("http://www.microsoft.com") ' Load Settings to Favorites menu when opening form For Each item As String In My.Settings.favList Dim menuItem1 As New ToolStripMenuItem menuItem1.Text = item.ToString ToolStripMenuItem1.DropDownItems.Add(menuItem1) Next 'Add Click Event handler for each Favorite link ToolStripMenuItem For Each C As ToolStripItem In ToolStripMenuItem1.DropDownItems If TypeOf (C) Is ToolStripMenuItem Then 'Exclude ToolStripSeparator items AddHandler C.Click, AddressOf ToolStripMenuItem_Click End If Next End Sub 'Add item to Favorites menu and FavList Settings Private Sub ToolStripMenuItem2_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _Handles ToolStripMenuItem2.Click Dim menuItem1 As New ToolStripMenuItem menuItem1.Text = WebBrowser1.Url.ToString ToolStripMenuItem1.DropDownItems.Add(menuItem1) My.Settings.favList.Add(WebBrowser1.Url.ToString) End Sub 'Open faverite link page when selecting link item from Faverite menu Private Sub ToolStripMenuItem_Click(ByVal sender As Object, _ ByVal e As System.EventArgs) WebBrowser1.Navigate(sender.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
Related thread:
http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/46729475-ffc5-4666-b4d0-f0d162a49acc
2) Here is the main idea to add Tabbed feature to your own web browser:
Add your Web Bowser to a new TabPage object, then add the TabPage object to the TabControl object.
e.g. How to open a new page in the 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
Here are some tutorials about Tabbed web browsers:
http://social.msdn.microsoft.com/Forums/en/vbgeneral/thread/827d96b1-2868-4624-ad32-10917d87a9ed
http://www.codeproject.com/KB/vb/TabPages.aspx
For more FAQ about Visual Basic .NET General, please see Visual Basic .NET General FAQ
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.- Marked As Answer by Xiaoyun Li – MSFT Saturday, April 11, 2009 11:40 AM

