i'm making a webbrowser. The user can add favorites, and there is a combobx that saves all the sites you typed in. But when i close a Form, all the text is lost. Now is my question: How do i save those things, so that the next i start my application, or open a form, my text is still there. Can someone plz send me a code sample.
Thanks in Forward,
radexxion

how to save usersettings
Fernando Correia
hi,
mmmm actualy i don't know , but once i asked a question about uri class and a kind guy sent to me this linke i guess its related to your question you can take a look even i didn't understand 2 lines after each other from it at least you can try
http://www.vbaccelerator.com/home/VB/Tips/Add_File_or_URL_AutoCompletion_to_TextBoxes_and_ComboBoxes/article.asp
Regarding to your forms configration you can take a look to this
http://www.devx.com/dotnet/Article/27562
http://odetocode.com/Articles/418.aspx
i don't know if that will help or not but i hope this will help
mtower
Unfortunately you can't bind an application setting to the Items collection of a combobox or list box, but it is not hard to do this yourself:
First I added a user scoped setting calls ComboBoxItems of type System.Collections.Specialized.StringCollection.
Next, I added the items to my list in the form load event. I also hooked up an event handler to the saving event that is fired before the settings are saved, and made sure that the string collection contained the items from my combobox:
Private WithEvents m_settings As My.MySettings = My.Settings
Private Sub PopulateComboBoxItemSetting(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles m_settings.SettingsSaving
My.Settings.ComboBoxItems.Clear()
For Each item As String In Me.ComboBox1.Items
My.Settings.ComboBoxItems.Add(item)
Next
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If My.Settings.ComboBoxItems Is Nothing Then
My.Settings.ComboBoxItems = New System.Collections.Specialized.StringCollection()
End If
For Each item As String In My.Settings.ComboBoxItems
Me.ComboBox1.Items.Add(item)
Next
End Sub
SJWhiteley, If you haven't already done so, I would recommend that you at least take a look at what the System.Configuration.ApplicationSettingsBase class will do for you. It has support for roaming settings, upgrade of settings between versions, allow you to do databinding, change how you persist your settings (an XML file is the default option)
Best regards,
Johan Stenberg
rev3nant
"and people who don't know what it is for, my delete the file or somethin."
Well you can always give it a file extention of .Dbf and make it look important.
peace
{{{{{"help militate for emoticons with hair!!!!!}
Murphy
Etienne2005
thanks for your help, but i still don't know how to do it.
I just want to save some text from a listbox, so that when the form closes, i can load it again. And it will be very usefull if i add a history tab or favorites tab onto my webbrowser.
i still hope someone can help me
thanks in forward,
eadexxion
StormChaser46678
weeeeeee, it works
thank you all for helping me
now i can finally try to create a nice webbrowser
thank you all
avs
I "played" with this for a few days, and i know how i can save most of the things, but i have one more question
How do i use this method with the treeview, because i want to save the Nodes, and the child nodes, but (I don't know why) i can't save those settings. Can you, or someone else, plz tell me how to save the Nodes and their childnodes with this method
thanks in forward,
Radexxion
Dusty
Johan,
Thanks. I'll look at it in a bit more detail, but the biggest issue I have is where the settings are saved, and the ability to save multiple settings files, and any settings file as specifed by the user. How would I specify a file name, for example
(This is similat to the issues I have with ClickOnce - location of the application to be installed, which may work fine in a user based environment, but 99% of the computers I work with are not in a user based environment , they are automation machines. In fact, if you could eliminate the 'user' functionality from WinXP, that'd make my life so much easier :) ).
wikino
WARNING: You must first have a setting made in your projects property window!
You first want to get the application to find ApplyChanges() String when the Apply Button is clicked:
Private Sub Apply_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click ApplyChanges() Me.Close() End Sub
The ApplyChanges String is put in the code somewhere:
Private Sub ApplyChanges() My.Settings.example = TextBox1.Text My.Settings.Save() End Sub
Then your application needs to read it when it loads:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Text = My.Settings.example
End Sub
And then your done, the application will save you setting then load it's text when your application is loaded. Told you it was easy....
iccle
srry for that, and thanks for your replay.
a friend of my just learned himself and me how to save into a text file.
This works fine for now, but the problem with txt files is that you have to create, and people who don't know what it is for, my delete the file or somethin.
i'll use this method now, but if someone has a better solution, plz share it with me.
all help is appreciated
thanks in forward,
radexxion
rellis32
thanks for your reply, it is very usefull, but i have stiil one question
How can i save all the items of a listbox or combobox
i can only set the displayed text from a combobox , and not the items in the ist you can't see
can you tell me plz if it is possible to save the items of a listbox and combobox with this method, and how
thanks in forward,
radexxion
grizzly
I think that may be a bit more complicated, however, I never use the user settings anyway, so I may have missed something.
However, my favorate method in .NET is to have all your application settings in a class, then serialize the class to an XML File.
If your setting requirements change (such as the values in a combo box), you can add it to the class and have a method in the class to populate a (the) combo box with your values.
By using a class (Called AppSettings, for example) you can keep all your global applications settings in one place.
Pat Meade
Use the application settings designer/client configuration API:
http://msdn2.microsoft.com/library/0zszyc6e(en-US,VS.80).aspx
http://msdn2.microsoft.com/library/wabtadw6(en-US,VS.80).aspx
Best regards,
Johan Stenberg
HemeFlasher
I'm not sure that the setting file is the best place to do that as far as practice is concerned. I think I'd save your data in a text file.
Secondly, it doesn't make a lot of sense to me to laugh at and be cross with people from whom you are asking assistance.