I created a webPanel at runtime with a webMemo and a webButton on it. Now I want to adjust the memo via webButtonClick. In the VCL I use FindComponent for this. Unfortunately that doesn't work (Result = nil). I am unable to solve this. Who knows an approach?
How to reproduce this?
I could not see a problem.
Test code:
procedure TForm3.WebButton1Click(Sender: TObject);
var
ctrl: TComponent;
begin
ctrl := FindComponent('WebMemo1');
console.log(ctrl);
end;
When i use this code:
procedure TfrmMain.WebButton1Click(Sender: TObject);
var
ctrl: TComponent;
begin
ctrl := FindComponent('consultPanel_0');
ShowMessage((ctrl as TWebPanel).Name);
end;
I get the message that ctrl is null. (consultPanel_0' is created in runtime)
I have no information how you create the control at runtime.
So, please isolate this issue in a sample source project with which we can reproduce this here so we can investigate.
Try to create a for loop and show all the components. Could be that the component 'consultPanel_0' has a different name. seems silly, but I had a similar problem in the past.
I would really appreciate if you could provide a sample source project that shows an issue so we can investigate. Otherwise, it is not time-efficient to do the trial & error here to guess your situation.
test - kopie.zip (7.7 KB)
FindComponent() works in the scope of the form class here. The memo you created & search for is a child of another panel and not the form and as such, is not found in the scope of the form.