Re:Populate combo box from array
On 18 May 2001 07:15:26 -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.
Well, it's not at all clear exactly where the array of names is
supposed to come from, and it seems quite clear that an array
of names is not the best thing regardless - whereever the
names come from sticking them into a TSTringlist or into
the combo box directly makes more sense.
But there's no problem shoving an array of strings into
a combobox:
var names: array[0..3] of string; j: integer;
begin
names[0]:= 'Tom';
names[1]:= 'dick';
names[2]:= 'Betty';
names[3]:= 'Sue';
for j:=0 to 3 do
begin
ComboBox1.Items.Add(names[j]);
end;
end;
David C. Ullrich
***********************
"Sometimes you can have access violations all the
time and the program still works." (Michael Caracena,
comp.lang.pascal.delphi.misc 5/1/01)