Mark Brady
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(memb er);
end;
end;
Thanks in advance
Mark
'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
var
i : integer;
member : string;
begin
for i:= 0 to combobox1.items.count -1 do
begin
member := combobox1.items[combobox1.
Radiogroup1.items.add(memb
end;
end;
Thanks in advance
Mark
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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 ???
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
ASKER
I'm sorry, you are right it does. Just for me being wreong, you can have the points. Thanks
Mark
Mark
ASKER
procedure TForm1.Button1Click(Sender
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.
Radiogroup1.items.add(memb
inc ( s );
end;
end;