我对Delphi FMX中的“无法在组件之间创建循环依赖”感到疯狂。我正在以编程方式在窗体上创建控件,其中一部分是标签,在网格内、滚动框内、网格内。
准则的相关部分包括:
Layout := TGridPanelLayout.Create(self);
Layout.Parent := self;
Panel := TVertScrollBox.Create(self);
Panel.Parent := Layout;
Form := TGridPanelLayout.Create(self);
Form.Parent := Panel;
FormLabel := TLabel(self);
FormLabel.Parent := Form;
它在我得到错误的最后一行。
具体来说,FMX中的第4387行。类型引发错误:
procedure TFmxObject.SetParent(const Value: TFmxObject);
begin
if Value = Self then
Exit;
if FParent <> Value then
begin
if IsChild(Value) then
raise EInvalidOperation.Create(SCannotCreateCircularDependence);
if FParent <> nil then
FParent.RemoveObject(Self);
if Value <> nil then
Value.AddObject(Self)
else
FParent := Value;
end;
end;
有人知道为什么会在一系列新的控制措施下提出这个问题吗?
有些代码没有包含在内,但它设置了行/列,不相关,但如果需要,我可以发布。
谢谢。