• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 191
  • Last Modified:

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
0
Mark Brady
Asked:
Mark Brady
  • 3
  • 3
1 Solution
 
Mark BradyPrincipal Data EngineerAuthor Commented:
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;
0
 
Slick812Commented:
procedure TForm1.Button1Click(Sender: TObject);
var
i : integer;
begin

for i:= 0 to combobox1.items.count -1 do
  begin
  Radiogroup1.items.add(combobox1.items[i]);
  end;
end;
0
 
Mark BradyPrincipal Data EngineerAuthor Commented:
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 ???
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Slick812Commented:
ask to delete
0
 
Slick812Commented:
and my code does add the text of the combobox items to the radio group
0
 
Mark BradyPrincipal Data EngineerAuthor Commented:
I'm sorry, you are right it does. Just for me being wreong, you can have the points.  Thanks

Mark
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now