Link to home
Start Free TrialLog in
Avatar of Mark Brady
Mark BradyFlag for United States of America

asked on

Naming items in a radiobox to match items in Combobox ?

I have a combobox1 with 6 items in it.

'Mark'
'John'
'Mary'
'Luke'
'Jasmin'
'Jerry'

The following code adds one item to radiogroup1 for each item in combobox1.  However, the way I have written the code it adds the name in combobox1.itemindex 6 times instead of naming each item separate.  

I need to have each radiogroup item with the name in the combobox.  Can you help out with this ?

Here's what I have

procedure TForm1.Button1Click(Sender: TObject);
var
i : integer;
member : string;
begin

for i:= 0 to combobox1.items.count -1 do
begin
member := combobox1.items[combobox1.itemindex];
Radiogroup1.items.add(member);
end;
end;



Thanks in advance

Mark
Avatar of Mark Brady
Mark Brady
Flag of United States of America image

ASKER

It's ok.  I have worked it out.  I changed the code to read this, and it works, thanks anyway...

procedure TForm1.Button1Click(Sender: TObject);
var
i, s : integer;
member : string;
begin

for i:= 0 to combobox1.items.count -1 do
begin
s := Combobox1.itemindex + 1;
combobox1.itemindex := ( s );
member := combobox1.items[combobox1.itemindex];
Radiogroup1.items.add(member);
inc ( s );
end;
end;
ASKER CERTIFIED SOLUTION
Avatar of Member_2_248744
Member_2_248744
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Slick
Two things wrong with that code.
1:  As you can see, I've already posted the correct result above.
2:  Your code adds the correct amount of items to radiobox1 but doesn't add the names in the combobox.  What I proposed above works just fine.  Thanks anyway

Mark

p.s.  How do I close this question off now ???
ask to delete
and my code does add the text of the combobox items to the radio group
I'm sorry, you are right it does. Just for me being wreong, you can have the points.  Thanks

Mark