Results 1 to 6 of 6

Thread: Problem creating Favorites Webbrowser

  1. #1
    Join Date
    Jan 2010
    Posts
    54

    Problem creating Favorites Webbrowser

    Here's what I try to do: Create favorite Webbrowser. Well, it's very simple, save all work. But the problem is: I want to have starred as the Webbrowser.documenttitle Text and when you click on it, the Webbrowser.url.tostring

    Here is my coding in several parts.
    Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim item1 As New ListViewItem
            item1.Name = TextBox2.Text
            item1.Text = TextBox1.Text
            FrmBase.ListView1.Items.Add(item1)
            My.Settings.FavList.Add(TextBox2.Text)
            My.Settings.HistoricCombobox.Add(TextBox1.Text)
            Me.Close()
        End Sub
     
    Private Sub ListView1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) _
    Handles ListView1.MouseUp
            Try
                Dim hti As ListViewHitTestInfo = ListView1.HitTest(e.Location)
                Dim url As String = hti.Item.Name
                CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(url)
     
    For Each item As String In My.Settings.FavList
                For Each itemm As String In My.Settings.HistoricCombobox
                    Dim item1 As New ListViewItem
                    item1.Name = item.ToString
                    item1.Text = itemm.ToString
                    ListView1.Items.Add(item1)
                Next
            Next

  2. #2
    Join Date
    Nov 2005
    Posts
    1,323

    Re: Problem creating Favorites Webbrowser

    As I see the code in My.Settings you created 2 object List (Of String). Be careful, the lists do not give you the guarantee to be indexed in order! In your code you do 2 loops so it is normal that you get dual values.

    I advise instead to create a dictionary in My.Settings SortedDictonnary or if it should be in alphabetical order.

    Then:
    My.Settings.MyDictionary = new Dictionary (Of String, String)
    Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim item1 As New ListViewItem
            item1.Name = TextBox2.Text
            item1.Text = TextBox1.Text
            FrmBase.ListView1.Items.Add(item1)
            My.Settings.MyDictionary.Add(TextBox2.Text,TextBox1.Text)
            Me.Close()
        End Sub
    Private Sub ListView1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) _
    Handles ListView1.MouseUp
            Try
                Dim hti As ListViewHitTestInfo = ListView1.HitTest(e.Location)
                Dim url As String = hti.Item.Name
                CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(url)
    For Each item as KeyValuePair(Of string,string) in My.Settings.MyDictionary
    dim item1 as New ListViewItem
    item1.Name = item..Key
    item1.Text = item.Value
    ListView1.Items.add(item1)
    Next

  3. #3
    Join Date
    Jan 2010
    Posts
    54

    Re: Problem creating Favorites Webbrowser

    Thank you very much for taking care of my little problems,

    But I do not really understand, I mean I am not able to go My.settings.dictionnary, the only I can take her:
    System.Collections.Specialized.StringDictionary

    With it, I can not code enlightens the beginning that we must enter:
    Code:
    My.Settings.MyDictionnary = new Dictionnary(Of string,string)
    and when I enter my favorite I get an exception error: Object reference not set to an instance of an object. and highlights in yellow the code:
    Code:
    My.Settings.MyDictionnary.Add(TextBox2.Text, TextBox1.Text)
    Thank you again, Little precision, I use VB 2008 Express Edition

    And also, while we're at it, how to make the Listview items Add with the code below (I mean, take the item and its Item.name item.Text)

    Code:
     For Each item As String In My.Settings.MyDictionnary 
     
                Dim item1 As New ListViewItem
                item1.Name = item.ToString
                item1.Text = item.ToString
                ListView1.Items.Add(item1)
            Next

  4. #4
    Join Date
    Nov 2005
    Posts
    1,323

    Re: Problem creating Favorites Webbrowser

    I had not realized you had gone through the design mode settings.

    The simplest is to create a variable in your application, ideally with a member of class type Dictionary (Of String,String) and then use this variable and no longer use My.Settings.

    Or create a variable or a structure in my namespace, but there it becomes more complicated.

    But if you want the listview to fill it from the start you must put it in your Form_Load and you need an external database to store your URL. (Either a database or txt file or XML)

  5. #5
    Join Date
    Jan 2010
    Posts
    54

    Re: Problem creating Favorites Webbrowser

    my question is: How does a Hastable? I never work with such a variable. And what happens if someone delete the XML file? Its probably procure the disorder. Basically, would not there have a way with Variable Dictionary to my items? I mean, use the dictionary to variable Item.name and another variable to the dictionary item.Text

  6. #6
    Join Date
    Nov 2005
    Posts
    1,323

    Re: Problem creating Favorites Webbrowser

    You can test this by simply creating a DataTable with 2 columns. You hit at the click of the button and then you save the XML with MyDatatable.WriteXML ("File Path"). And in the Form_Load you done conversely MyDataTable.ReadXML ("File Path")

Similar Threads

  1. JDIC - Problem to close a WebBrowser
    By Gunner 1 in forum Software Development
    Replies: 6
    Last Post: 14-01-2010, 05:19 PM
  2. How to control WPF Webbrowser
    By Dharmesh Arora in forum Software Development
    Replies: 3
    Last Post: 13-07-2009, 09:58 AM
  3. Problem with Avant Browser Favorites ?
    By RAIDEN in forum Technology & Internet
    Replies: 4
    Last Post: 31-03-2009, 07:09 PM
  4. C#: How to access webBrowser child window
    By moshe2b in forum Software Development
    Replies: 1
    Last Post: 06-02-2009, 11:50 PM
  5. Favorites shortcut problem
    By Salome in forum Operating Systems
    Replies: 2
    Last Post: 30-01-2009, 06:23 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,570,732.71939 seconds with 17 queries