Question[Help] Save Items in Combobox[Solved]

Posts 1–9 of 9 · Page 1 of 1
[Help] Save Items in Combobox[Solved]
Is there a way to save the items currently in a comx using settings?
Goto Properties / Settings (Your application settings)
[Right click application name in solution explorer, Properties, settings tab)

Saving a single Item

Click the Settings Name and create a new setting, Calling it Combobs
Set it's type to string

* Form Load
- Loads saved Values
[php]
Me.ComboBox1.Text = My.Settings.Combobs
[/php]

*Form Closing
-This code sets the settings when the form is closing

Or you can add it as a button event

However you want.

Saving Multiple Items

Create the same setting as above (combobs) Except it's type will be Specialized.StringCollection [system.Collections.Specialized.StringCollection]

* For Load
-Loads Settings

[php]
If My.Settings.combobs IsNot Nothing Then
For Each Item As String In My.Settings.combobs
ComboBox1.Items.Add(Item)
Next
Else
My.Settings.combobs = New System.Collections.Specialized.StringCollection
End If
[/php]

Save Settings, Button or Form Closing

[php]
If ComboBox1.Items.Count > 0 Then
My.Settings.combobs.Clear()
For Each Item2 As String In ComboBox1.Items
My.Settings.combobs.Add(Item2)
Next
My.Settings.Save()
End If
[/php]

Thanx Man, Best Vb Minion
Not a problem, there is a problem though, I am correcting it in the code
hehe after debugging theres an error... Lol
For Each item As String In My.Settings.Combobs
Fixed, Should work fine.


Have Fun

Works Perfectly, Thanks
Marked Solved, Left open for other users.
Avoid posting unless under 7 days & Necessary

Glad to help
Another day saved by NextGen, great explanation.
Posts 1–9 of 9 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us