У меня есть TabControl с некоторыми TabItems.Один из них динамически заполнен рамками.![enter image description here](https://i.stack.imgur.com/VCKW4.png)
var
item: TListBoxItem;
currentFrame: TFrame;
frameIndex: integer;
begin
if Sender is TListBoxItem then
item:= TListBoxItem(Sender)
else
Exit;
FindAndDeleteItemContext;
frameIndex:= GetFrameIndexByText(item);
{factory}
FFramesFactory:= TFramesFactory.DefaultFactory;
{new frame}
currentFrame:= FFramesFactory.GetFrame(frameIndex);
{add to layout}
currentFrame.Parent:= TabItemContent;
currentFrame.Align:= TAlignLayout.Client;
// TabItemContent.AddObject(currentFrame);
TabItemContent.InsertComponent(currentFrame);
{open tab}
ActionToContentTabExecute(Sender);
end;
В FFramesFactory кадры генерируются следующим образом:
TFrame_Map.Create(nil)
Перед тем, как добавить новый кадр, который я хочу найти, иудалить старую рамку, не освобождая ее в памяти.
procedure Txxx.FindAndDeleteItemContext;
var
i: Integer;
begin
for i:= 0 to Pred(TabItemContent.ComponentCount) do
begin
if TabItemContent.Components[i] is TFrame then
begin
TabItemContent.RemoveComponent(TabItemContent.Components[i]);
Exit;
end;
end;
end;
, но это не работает.Я могу найти кадр, но не могу удалить его, и я вижу оба кадра в табите.
Как я могу удалить найденный кадр?
Заранее спасибо.