1,105,177 Community Members

Recording Data

Member Avatar
IsaacMessi10
Junior Poster in Training
83 posts since Aug 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 6 [?]
 
0
 

I'm working on a web browser and I need to know how to store history & bookmarks permanently as currently after the browser is closed all data is lossed.

Should I put it on a DB? Suggestions?

PS: They are currently being saved on a ListBox.

Member Avatar
Philippe.Lahaie
Posting Whiz
376 posts since Oct 2007
Reputation Points: 42 [?]
Q&As Helped to Solve: 60 [?]
Skill Endorsements: 9 [?]
 
0
 

a database would probly be overkill for this, i believe most browsers just use text files or at most an xml to store favorites.

Member Avatar
TnTinMN
Practically a Master Poster
640 posts since Jun 2012
Reputation Points: 418 [?]
Q&As Helped to Solve: 152 [?]
Skill Endorsements: 16 [?]
 
2
 

An easy way to do this is to create a string collectionin My.Settings.

usersetting

You can add/delete from it like any other list. Set it as the Listbox's DataSource.
ListBox1.DataSource = My.Settings.History

Just make sure that user settings is set to automatically save or do it in your code in the form closed event handler.

 Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
   My.Settings.Save()
End Sub

Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
My.Settings.Save()
End Sub

Member Avatar
IsaacMessi10
Junior Poster in Training
83 posts since Aug 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 6 [?]
 
0
 

^^^ didn't work :(

Member Avatar
TnTinMN
Practically a Master Poster
640 posts since Jun 2012
Reputation Points: 418 [?]
Q&As Helped to Solve: 152 [?]
Skill Endorsements: 16 [?]
 
0
 

Well gee, with such an informative description of the problem, all I can say is you did it wrong.

Member Avatar
G_Waddell
Practically a Posting Shark
821 posts since Nov 2009
Reputation Points: 131 [?]
Q&As Helped to Solve: 137 [?]
Skill Endorsements: 13 [?]
 
0
 

@IsaacMessi10
What happened did you get an error? What did it say? Show us your code...

Member Avatar
IsaacMessi10
Junior Poster in Training
83 posts since Aug 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 6 [?]
 
0
 

Well there were no syntax errors. Just when I published the project, I went to Google and I closed the program. I reopened it and found no records of me going to Google and I've done as @TnTinMN told me. :(

Member Avatar
IsaacMessi10
Junior Poster in Training
83 posts since Aug 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 6 [?]
 
0
 
Public Class HistoryClass

    Private Sub HistoryList_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HistoryList.SelectedIndexChanged
        HistoryList.DataSource = My.Settings.History
    End Sub

    Private Sub Delete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Delete.Click
        HistoryList.Items.Clear()
    End Sub

    Private Sub Remove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Remove.Click
        If (HistoryList.SelectedIndex >= 0) Then
            HistoryList.Items.RemoveAt(HistoryList.SelectedIndex)
        End If
    End Sub

    Private Sub Open_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Open.Click
        If (HistoryList.SelectedIndex >= 0) Then
            Form1.WebBrowser.Navigate(HistoryList.SelectedItems(0))
        End If
    End Sub
End Class
Attachments List_error.png 57.76KB
Member Avatar
G_Waddell
Practically a Posting Shark
821 posts since Nov 2009
Reputation Points: 131 [?]
Q&As Helped to Solve: 137 [?]
Skill Endorsements: 13 [?]
 
0
 

Hi,
Where do you actually write the entry to your setting? Are you saving the updated setting?

Member Avatar
IsaacMessi10
Junior Poster in Training
83 posts since Aug 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 6 [?]
 
0
 

Yes in the main form just before it closes.

Member Avatar
TnTinMN
Practically a Master Poster
640 posts since Jun 2012
Reputation Points: 418 [?]
Q&As Helped to Solve: 152 [?]
Skill Endorsements: 16 [?]
 
0
 

Here is a very crude webbrowser example that maintains two history listes. It may give you some ideas. This example uses datatables instead of a string collection.

Attachments WindowsApplication42.zip (13.77KB)
Member Avatar
IsaacMessi10
Junior Poster in Training
83 posts since Aug 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 6 [?]
 
0
 

tks a lot m8

Question Answered as of 11 Months Ago by TnTinMN, G_Waddell and Philippe.Lahaie
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article