Urgent: Retrieve a control in runtime application
Posted on 2002-05-15
Can some one help me to do this:
I had dinamically created several component (CheckBox) during the runtime. So, i need to check the "Checked" property of the checkboxes after a buttonclick, but i can't get the component by code.
//this code repeat several times
With TCheckBox.Create(Self) do
Name := 'chk_' + IntToStr(i+1);
// I try to do it this way...
procedure TForm1.btnClick(Sender: TObject);
ctrls, i : Integer;
CtrlName : string;
ctrls_No := 1;
for ctrls := 0 to Form1.ControlCount-1 do
CtrlName := Form1.Controls[ctrls].ClassName ;
if CtrlName = 'TCheckBox' then begin
How can I set the "ctrls".Checked = True to this
normal:if chk_1.Checked then begin ..do something
Current situation: How??
I plan to use some codes like in the VB:
foreach ctrl in ctrls
if ctrl.checked = true then