Hi!
I am creating several ToolBars in Form1.
For a ToolBar with specific Tag I need to enable a button with specific name that has parent this ToolBar.
I can find the ToolBar by parsing the Form1 elements as below.
PROCEDURE TForm1.OnChange_EditVal(Sender : TObject);
VAR
theTag : INTEGER;
i, j : INTEGER;
theparent : TWinControl;
element_name : STRING;
BEGIN
WITH (Sender as TCDEdit) DO
theTag := (Sender as TCDEdit).Tag; //Get the Tag aka Row
FOR i := 0 TO TWinControl(Form1).ControlCount - 1 DO
IF TWinControl(Form1).Controls[i] is TBCToolBar THEN
BEGIN
theparent := TWinControl(Form1).Controls[i];
if theparent.Name := inttostr(theTag) then begin
FOR j := 0 TO TWinControl(theparent).Components[j] DO //does not work: main.pas(282,43) Error: Incompatible types: got "TComponent" expected "LongInt"
BEGIN
element_name := TWinControl(theparent).Controls[j].Name;
IF element_name = btnPostUpdateName + IntToStr(theTag) THEN
BEGIN
TWinControl(Form1).Controls[i].Enabled := True; //Enable the button
break;
END;
END;
end;
END;
END;
How would I find the button once I have the ToolBar?
Thank you.