473,386 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to populate a combobox with an ArrayList containing 1 dimensional array of strings?

All the examples I've seen showing how to populate a combobox using the
DataSource property and an ArrayList show the ArrayList object
containing objects with at least two properties. I want to create an
ArrayList that contains only rows of string data and want to assign
this to the DataSource but I can't figure out what to set the
ValueMember or DisplayMember to. Example

ArrayList myData = new ArrayList();

myData.Add("abc");
myData.Add("def");

ComboBox combo = new ComboBox();
combo.DataSource = myData;
combo.ValueMember = ???
combo.DisplayMember = ???

Oct 10 '06 #1
4 28207
Hi,

Don't set anything. If this properties are not set the combobox will use the
object itself as display and value member. You need this properties only if
you set up the combobox with collection of complex objects - that have
properties on their own and you one use them to provide the visual and the
value.
--
HTH
Stoitcho Goutsev (100)

<po********@gmail.comwrote in message
news:11**********************@c28g2000cwb.googlegr oups.com...
All the examples I've seen showing how to populate a combobox using the
DataSource property and an ArrayList show the ArrayList object
containing objects with at least two properties. I want to create an
ArrayList that contains only rows of string data and want to assign
this to the DataSource but I can't figure out what to set the
ValueMember or DisplayMember to. Example

ArrayList myData = new ArrayList();

myData.Add("abc");
myData.Add("def");

ComboBox combo = new ComboBox();
combo.DataSource = myData;
combo.ValueMember = ???
combo.DisplayMember = ???

Oct 10 '06 #2
Bry

po********@gmail.com wrote:
All the examples I've seen showing how to populate a combobox using the
DataSource property and an ArrayList show the ArrayList object
containing objects with at least two properties. I want to create an
ArrayList that contains only rows of string data and want to assign
this to the DataSource but I can't figure out what to set the
ValueMember or DisplayMember to. Example

ArrayList myData = new ArrayList();

myData.Add("abc");
myData.Add("def");

ComboBox combo = new ComboBox();
combo.DataSource = myData;
combo.ValueMember = ???
combo.DisplayMember = ???
Do you need to use a DataSource?

Why not just use the following:

ArrayList myData = new ArrayList();
myData.Add("abc");
myData.Add("def");

foreach (string s in myData)
combo.Items.Add(s);

Bry

Oct 10 '06 #3
I want to avoid using a loop.

On Oct 10, 11:54 pm, "Bry" <bryanhob...@gmail.comwrote:
polaris...@gmail.com wrote:
All the examples I've seen showing how to populate a combobox using the
DataSource property and an ArrayList show the ArrayList object
containing objects with at least two properties. I want to create an
ArrayList that contains only rows of string data and want to assign
this to the DataSource but I can't figure out what to set the
ValueMember or DisplayMember to. Example
ArrayList myData = new ArrayList();
myData.Add("abc");
myData.Add("def");
ComboBox combo = new ComboBox();
combo.DataSource = myData;
combo.ValueMember = ???
combo.DisplayMember = ???Do you need to use a DataSource?

Why not just use the following:

ArrayList myData = new ArrayList();
myData.Add("abc");
myData.Add("def");

foreach (string s in myData)
combo.Items.Add(s);

Bry- Hide quoted text -- Show quoted text -
Oct 11 '06 #4
Isn't my previous post help you?
--
Stoitcho Goutsev (100)
<po********@gmail.comwrote in message
news:11*********************@i42g2000cwa.googlegro ups.com...
>I want to avoid using a loop.

On Oct 10, 11:54 pm, "Bry" <bryanhob...@gmail.comwrote:
>polaris...@gmail.com wrote:
All the examples I've seen showing how to populate a combobox using the
DataSource property and an ArrayList show the ArrayList object
containing objects with at least two properties. I want to create an
ArrayList that contains only rows of string data and want to assign
this to the DataSource but I can't figure out what to set the
ValueMember or DisplayMember to. Example
ArrayList myData = new ArrayList();
myData.Add("abc");
myData.Add("def");
ComboBox combo = new ComboBox();
combo.DataSource = myData;
combo.ValueMember = ???
combo.DisplayMember = ???Do you need to use a DataSource?

Why not just use the following:

ArrayList myData = new ArrayList();
myData.Add("abc");
myData.Add("def");

foreach (string s in myData)
combo.Items.Add(s);

Bry- Hide quoted text -- Show quoted text -

Oct 17 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Venkat | last post by:
Hi All, I need to copy strings from a single dimensional array to a double dimensional array. Here is my program. #include <stdio.h> #include <stdlib.h>
1
by: Reginald Carlier | last post by:
Hi, I'm programming a game and one of the variables is a two dimensional array in wich I store the names of the players. So far so good; with cin.get I ask the names of the players and...
3
by: ZeroVisio | last post by:
Hi, Is it possible to create two -dimensional array using ArrayList in C#? I know you can do one-dimensional array but i dont know how to do two-dimensional. in my case my number of columns...
1
by: Mohan | last post by:
Hi, In my application, I need to increase the 2-dimensional array size dynamically. Please let me know the procedure to declare a dynamic 2-dimensional array like Single dimensional array,...
16
by: rguti | last post by:
Hi, How do I create a two dimensional array? I have created a one dimensional doing this: Dim laFields As ArrayList = New ArrayList How about to do a 2 dimensional?
4
by: Tad Marshall | last post by:
Hi, I'm reading about arrays in VB.NET and I seem to have a few options for my data structure. I need a multi-dimensional array of structures, and my first thought was Public Structure myStr...
5
by: XML newbie: Urgent pls help! | last post by:
function to convert string to 1 dimensional array of long in VB.Net
6
by: fniles | last post by:
I need to store information in a 2 dimensional array. I understand ArrayList only works for a single dimensional array, is that correct ? So, I use the 2 dimensional array like in VB6. I pass the...
8
by: per9000 | last post by:
Hi all, I have a two-dimensional array of data, f.x int's. We can imagine that the array is "really large". Now I want the data in it and store this in a one-dimensional array. The obvious...
10
by: SM | last post by:
Hello I'm trying to create a multi dimensional array in JavaScript, but after some reading i still can't figure out how to apply it to my model. Here it is: I have a list A and for each item...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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,...

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.