|
-
Apr 13th, 2008, 11:30 PM
#1
Thread Starter
Hyperactive Member
[2005] Saving this items
Hi to all,
im creating a webbrowser, with a favorites function using a listbox and a bindingsource and this is how i did it :
with help of this forum i created a sort of custom object, ill post it here :
Vb .net Code:
Public Class Favorites
Private _title As String
Private _url As String
Public Property Title() As String
Get
Return Me._title
End Get
Set(ByVal value As String)
Me._title = value
End Set
End Property
Public Property Url() As String
Get
Return Me._url
End Get
Set(ByVal value As String)
Me._url = value
End Set
End Property
Public Sub New(ByVal title As String, ByVal url As String)
Me._title = title
Me._url = url
End Sub
End Class
and the code i use to add new items to the listbox is this :
add new item
Vb .net Code:
Dim N As Integer
N = Favs.FindStringExact(Applicationhelper _
.CurrentBrowser.DocumentTitle)
If (N = -1) Then
Me.Listoffavorites.Add(New Favorites(Applicationhelper _
.CurrentBrowser.DocumentTitle, Applicationhelper _
.CurrentBrowser.Url.ToString))
End If
set the data to the listbox
Vb .net Code:
Dim Listoffavorites As New System.ComponentModel.BindingList(Of Favorites)
Me.BindingSource1.DataSource = Me.Listoffavorites
Me.Favs.DisplayMember = "Title"
Me.Favs.ValueMember = "Url"
Me.Favs.DataSource = Me.BindingSource1
well, now that i described what i have done ill tell u what i want to do
i want to save those items in a textbox or in anyway, can anyone help me ?
thanks
-
Apr 13th, 2008, 11:37 PM
#2
Re: [2005] Saving this items
I don't know what you mean by saving them to a TextBox.
-
Apr 13th, 2008, 11:38 PM
#3
Thread Starter
Hyperactive Member
Re: [2005] Saving this items
sorry, i made a mistake i want to save them into a *TEXT FILE
-
Apr 13th, 2008, 11:54 PM
#4
Re: [2005] Saving this items
Do you have a specific format in mind for this file? If not I'd suggest using XML. You can serialise a collection of your objects to a file in about four lines of code, then deserialise the file back to a collection in the same. Search the forum for XmlSerializer and you should find examples.
-
Apr 14th, 2008, 09:29 AM
#5
Thread Starter
Hyperactive Member
Re: [2005] Saving this items
ive been searching the forum for xmlSerializer examples, but there no thread that can help me, i tried this code but nothing happends....:
to deserialize the file:
Vb .net Code:
Dim n As New Runtime.Serialization.Formatters.Binary.BinaryFormatter
Dim ss As New IO.FileStream("C:\Users\Pablo\Documents\set.bin", IO.FileMode.Open)
listoffavorites = CType(n.Deserialize(ss), Global.System.ComponentModel.BindingList(Of Favorites))
ss.Close()
to sereliaze the file
Vb .net Code:
Dim s As New Runtime.Serialization.Formatters.Binary.BinaryFormatter
Dim n As New IO.FileStream("C:\Users\Pablo\Documents\set.bin", IO.FileMode.Create)
s.Serialize(n, listoffavorites)
n.Close()
nothing happends while using this codes what i want to do its save all the favorites item that are currently in listoffavorites, and load them again at form load but i have no idea on how to do this, maybe its by xmlserializer but i dont know how to use this i searched in msdn but i found nothing, so i will really apreciate if someone help....thanxs
-
Apr 14th, 2008, 01:06 PM
#6
Thread Starter
Hyperactive Member
Re: [2005] Saving this items
-
Apr 14th, 2008, 04:33 PM
#7
Re: [2005] Saving this items
I just searched the VB.NET forum for xmlserializer and this was the second result, after this very thread. I'm guessing that's where you got that code from but at the end it has an example of using an XmlSerializer. You really didn't look very hard.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|