Best strategy for too many Elements in FireMoneky TListView Item [duplicate]

人走茶凉 提交于 2019-11-29 08:55:10

I am not sure that my way was correct, but I was using TListbox for alike purpose in my fmx project. The structure of its items was formed in the following way during filling from DataSource by LiveBindings.

procedure THMICD10Fr.LinkListControlToField1FillingListItem(Sender: TObject;
  const AEditor: IBindListEditorItem);
begin
  if (Assigned(AEditor)) and (HDM2.FDQicd_detail_for_TreeView.Active) then
    try
      if (AEditor.CurrentObject as TMetropolisUIListBoxItem).ChildrenCount = 2
      then
      begin

        with TPanel.Create(AEditor.CurrentObject as TMetropolisUIListBoxItem) do
        begin
          Parent := (AEditor.CurrentObject as TMetropolisUIListBoxItem);
          Align := TAlignLayout.alRight;
          Width := 45;
          Margins.Bottom := 1;
          Margins.Top := 1;
        end;

        with TLabel.Create((AEditor.CurrentObject as TMetropolisUIListBoxItem)
          .Children.Items[2] as TPanel) do
        begin
          Parent := (AEditor.CurrentObject as TMetropolisUIListBoxItem)
            .Children.Items[2] as TPanel;
          Text := '↓';
          VertTextAlign := TTextAlign.taCenter;
          TextAlign := TTextAlign.taCenter;
          Align := TAlignLayout.alClient;
          HitTest := true;
          AutoSize := false;
          StyledSettings := StyledSettings - [TStyledSetting.ssStyle];
          Font.Style := Font.Style + [TFontStyle.fsBold];
          Tag := HDM2.FDQicd_detail_for_TreeView.FieldByName('id').AsInteger;
          TagString := HDM2.FDQicd_detail_for_TreeView.FieldByName
            ('category_etiology').AsString;
          OnClick := LabelInListBox1Click;
        end;
      end;

    except

    end;
end;

This code gave me the following appearence:

You can create and nest all necessary TLayouts, TLabels etc. inside the Item and set all the necessary settings using the logics from inside the LiveBindings event handler.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!