LucieLastic
Programmer
hi all
I'm trying to add some radio buttons to a radiogroup at runtime but can't get it to work. I've tried the items.addobject because I need to store the id and explicitly creating the radio buttons but to no avail:
I'm trying to add some radio buttons to a radiogroup at runtime but can't get it to work. I've tried the items.addobject because I need to store the id and explicitly creating the radio buttons but to no avail:
Code:
procedure TDataModMain.GetRadioButtons(radiogroup : TRadioGroup; sql : string);
var Dataset : TADODataset;
radio : TRadioButton;
begin //SQL must come in "select ID, Desc" order!!!
Dataset := TADODataset.create(self);
TRY
radiogroup.items.clear;
Globalaccess.RunSQL(_Database, sql, Dataset);
while not Dataset.eof do
begin
radio := TRadioButton.create(self);
radio.parent := radiogroup;
radio.caption := Dataset.fields[1].asstring;
radio.tag := Dataset.fields[0].asinteger;
// radiogroup.items.addobject(Dataset.fields[1].asstring, pointer(Dataset.fields[0].asinteger));
Application.processmessages;
Dataset.next;
end;
FINALLY
Dataset.close;
FreeAndNil(Dataset);
END;
end;