Board index » delphi » Poulating a combo box from an array

Poulating a combo box from an array

I am creating a basic program to store user information using arrays,
and would like to include a combo box on a form from which a user can
choose his/her name, and vierw their information.  As this is for a
university project, I have been told to use arrays, rather than DB
functions.  I anm having trouble with the code to populate the combo
box, and would much appreciate any help in this matter.

Thanks,

Dom Boyce

 

Re:Poulating a combo box from an array


On 18 May 2001 07:14:30 -0700, dombo...@totalise.co.uk (Dom Boyce)
wrote:

Quote
>I am creating a basic program to store user information using arrays,
>and would like to include a combo box on a form from which a user can
>choose his/her name, and vierw their information.  As this is for a
>university project, I have been told to use arrays, rather than DB
>functions.  I anm having trouble with the code to populate the combo
>box, and would much appreciate any help in this matter.

>Thanks,

>Dom Boyce

In the online help, look up TComboBox. See property Items. This is the
list that drops down. Items is made of TStrings. Look that up,
especially the Add method.

You should be able to loop through your array, adding each name to the
list. You can create a TList object, add the names, then assign the
list to the combo box, or just add the items dirctly to the list
property:
   mycombobox.Items.Add(array[i]);

HTH,
Dan
--
Dan Brennand
CMDC systems, inc.
Configuration Management and Document Control:
visit us at www.cmdcsystems.com
[SPAM block: change at to @ in my e-mail address]

Re:Poulating a combo box from an array


Lets assume you have array caled AR.

For i:=Low(AR) to High(AR) do comboBox1.items.add(AR[i]);

In article <7c016cf5.0105180614.5aac3...@posting.google.com>,
dombo...@totalise.co.uk says...

Quote
> I am creating a basic program to store user information using arrays,
> and would like to include a combo box on a form from which a user can
> choose his/her name, and vierw their information.  As this is for a
> university project, I have been told to use arrays, rather than DB
> functions.  I anm having trouble with the code to populate the combo
> box, and would much appreciate any help in this matter.

> Thanks,

> Dom Boyce

Other Threads