How to implement the function of cleaning dynamically created Image? I create Image in a cycle. His name is:

ArrOfImage[i].Name :='ImgP'+IntToStr[i]; .... ( куча остальных свойств) ArrOfImage[i].Paren := TabSheepArrP[i]; // ну тут соответственно размещение на TabSheep который тоже создается программно. ( Все создается в 1 цикле => друг другу соответствует. 

It is necessary to clear all the Image with the same name.

I do this:

 for fmMain.PageControl2.ControlCount-1 downto 0 do // Все это создается как вы поняли на 2-ом PageControl begin if Pos('ImgP',fmMain.PageControl2.Controls[i].Name) <> 0 then TImage(fmMain.PageControl2.Controls[i]).Picture := nil; end; 

It seems to be logical, and it should work, but for some reason fmMain.PageControl2.ControlCount = 1 and the Name of this control is the name of TabSheet , and as I understand it it does not see the Image .

Tell me how to solve this problem?

PS: If something helps: I try to get a link to Image using FindComponent , the function returns nil .

  • Dinamic , Paren , correct typos - Kromster

2 answers 2

So it is necessary to post not only the task of the parent, but also to addControl (or I don’t remember something like that), it is not automatically added to the list of controls of the party.

    Create on the tab, and look for on pagecontrol.

    will look something like this

     var i,z:integer; begin i:=pc.Pages[0].ControlCount; for z := 0 to i-1 do begin showmessage( pc.Pages[0].Controls[z].Name) ; end; 

    end;

    PC = PageControl

    instead of Showmessage, you are already making your condition.