|
-
Jun 15th, 2009, 06:16 AM
#1
Thread Starter
Lively Member
[RESOLVED] How to Save Combobox Items in MySettings?
Well currently I'm needing to store various settings, strings, integers, items, etc, within the program settings. So far this has gone without a snag and is working as planned except for one thing, Comboboxes. I have browsed through the various types of settings I can save to and the closest is a "System.Collection.Specialized.StringCollection", however VB is throwing up an error saying that:
Error 1 Value of type 'System.Windows.Forms.ComboBox.ObjectCollection' cannot be converted to 'System.Collections.Specialized.StringCollection'. C:\Users\User\AppData\Local\Temporary Projects\Project\Form1.vb 12 34 Project
So my question is this; How would I go about saving the items in a Combobox?
Thanks.
-
Jun 15th, 2009, 06:34 AM
#2
Re: How to Save Combobox Items in MySettings?
try this:
vb Code:
Dim strings(ComboBox1.Items.Count - 1) As String
ComboBox1.Items.CopyTo(strings, 0)
My.Settings.SettingName.Clear()
My.Settings.SettingName.AddRange(strings)
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 15th, 2009, 06:38 AM
#3
Re: How to Save Combobox Items in MySettings?
to reload:
vb Code:
Dim strings(My.Settings.SettingName.Count - 1) As String
My.Settings.SettingName.CopyTo(strings, 0)
ComboBox1.Items.AddRange(strings)
Last edited by .paul.; Jun 15th, 2009 at 06:48 AM.
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 15th, 2009, 06:45 AM
#4
Thread Starter
Lively Member
Re: How to Save Combobox Items in MySettings?
Thankyou so much .paul.! All problems now fixed (hopefully). :P Thanks so much for your help.
Last edited by PR0 6AM3R; Jun 15th, 2009 at 06:56 AM.
-
Jun 15th, 2009, 07:46 AM
#5
Lively Member
Re: [RESOLVED] How to Save Combobox Items in MySettings?
Sorry paul but tell me
i met error when using your code. may be i have not declared something yet.
Code:
'SettingName' is not a member of 'WindowsApplication9.My.MySettings'. D:\CHƯƠNG TRÌNH CHÍNH\GIAO DIỆN\formappearstyle\WindowsApplication9\WindowsApplication9\Form1.vb
-
Jun 15th, 2009, 08:02 AM
#6
Re: [RESOLVED] How to Save Combobox Items in MySettings?
in your design time IDE goto (menus)
Project-->Properties-->Settings
add a new setting, change the type to specialized.stringcollection, click the box in the value column, then click the ellipsis at the far right of the value box. press enter then click OK. you now have a specialized.stringcollection setting
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 15th, 2009, 10:06 AM
#7
Lively Member
Re: [RESOLVED] How to Save Combobox Items in MySettings?
Ok thanks Paul. It works too.
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
|