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

佐手、 提交于 2019-12-18 05:24:27

问题


Believe me I did my homework before reaching out for help. I spent last 3 days searching and reading but I couldn't come to a solution. So any help will be highly appreciated.

My task is to have a ListView connected to a Dataset where the ListView Item is of the following structure:

Bear in mind that

  1. Elements 4, 6, & 8 are of fixed values & Color (i.e. labels)
  2. Colors of Elements 1 & 10 depends on values of Elements 5, 7, & 9

Best what I got is references to Delphi Standard Example that shifts with Embarcadero Delphi Examples directory: ListViewMultiDetailAppearance. This solution offers to create our own class for MutliDetailItemAppearance and register as many details as we need (in my case I need additional 8 I think).

Now my questions:

  1. Is this the best approach?
  2. if not, what is the better approach?
  3. if it is, how adding additional 8 details will affect the performance?
  4. and most important how to reach custom coloring for elements for each List View Item based on the values?
  5. and finally how to reach this sections borders? and List item bottom borders (the green line)?

Thank you very much for your thoughts in advance.


回答1:


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.



来源:https://stackoverflow.com/questions/32008550/best-strategy-for-too-many-elements-in-firemoneky-tlistview-item

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