473,492 Members | 4,279 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Bind application settings to ComboBox items

125 New Member
So i'm using VS 2005 and VB.

My ultimate goal is to make a ComboBox with the items from the stored settings. The setting is of the type StringCollection (System.Collections.Specialized.StringCollection).

In the design mode you cant find the Items property for the combobox in the Application settings.

Settings help page: http://msdn.microsoft.com/en-us/libr...4c(VS.80).aspx

My current code does works but not good. But if i can convert the StringCollection to a string array in a better way than i'm doing now the that wold be a good solution.

I have added a setting with the StringCollection type. Then in Form1_Load i do this:

Expand|Select|Wrap|Line Numbers
  1. StringArr = New String() {"1", "2", "3", "4"}
  2. My.Settings.Item("StringCollectionName").CopyTo(StringArr, 0)
  3. ComboBox1.Items.AddRange(StringArr)
It works if StringCollectionName has 4 objects, but thats wery bad. Then you can only change settnings, not add or remove withut changing the number. I'm quite new to .NET so i have problems converting this StringCollection to a 1-dimensional array of strings. Maybe you can check the lengt of StringCollectionName or somthing like that to...

The CopyTo:
http://msdn.microsoft.com/en-us/libr...on.copyto.aspx
Jul 16 '08 #1
1 4186
asedt
125 New Member
Expand|Select|Wrap|Line Numbers
  1. Dim b(My.Settings.Item("NameOfSetting").Count - 1) As String
  2. My.Settings.Item("NameOfSetting").CopyTo(b, 0)
  3. ComboBox1.Items.AddRange(b)
It's better than before, it works but maybe anuone know a better way?
Jul 16 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
6355
by: Rachel Suddeth | last post by:
When I put a ComboBox on a form, I can enter strings through the designer to fill Items collections. I have put a ComboBox in a UserControl, and exposed the the Items collections with the same...
2
1958
by: Alpha | last post by:
I have a window application. On one of the form, there is a listbox and a few combox. The lstSchItem has a dataview as a datasource. The comboxes are bind to its selected value but through the...
1
15019
by: Mike Hofer | last post by:
I am trying to do something a little nonstandard, and am having some difficulty determining (a) if it can be done and (b) if so, how to do it. What I want to do is fill a dropdown combobox with...
5
25827
by: James P. | last post by:
Hello, For my new Windows application, all I want is to create an initial form to demo to the user to show them how it looks like with some data on it. So I figure the fastest way is to create...
6
7792
by: Sakharam Phapale | last post by:
Hi All, How to fill one ComboBox from other ComboBox control? 1) Only setting the reference does the trick but doesn't show items in control. If you see in immediate window, it shows...
7
1893
by: samoore33 | last post by:
I am trying to dynamically add items to a listbox or combobox. The items add to either, but when I look through those items, there is nothing there. If I choose an item, it shows up. Not sure...
1
1392
by: Harry | last post by:
I have two tables in a database. One fills the drop-down and the other records the selection. Filling the dropdown with another table seems to be breaking the binding with the table it records to....
5
6776
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I want to create a customized ComboBox where the methods ComboBox.Items.Add and ComboBox.Items.Insert will behave thusly: -- If the item is not present, add it. -- If the item is present, set the...
0
2566
by: pavanip | last post by:
Hi, I am facing problem with combobox in gridview.I have used combobox in gridview and i am binding data to gridview combobox from database. If i click 2 times on combobox then it is showing the...
0
7118
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6980
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6862
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7364
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1397
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
637
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
282
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.