FireMoneky TListView项目中太多元素的最佳策略 [英] Best strategy for too many Elements in FireMoneky TListView Item

查看:443
本文介绍了FireMoneky TListView项目中太多元素的最佳策略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

相信我已经做好了家庭作业,然后才开始寻求帮助。我花了最后3天搜索和阅读,但我无法解决问题。所以任何帮助将被高度赞赏。



我的任务是将ListView连接到ListView项目具有以下结构的数据集:



请记住,


  1. 元素4,6,& 8是固定值&颜色(即标签)

  2. 元素的颜色1& 10取决于元素5,7和& 9

最好的是引用Delphi标准示例,用Embarcadero Delphi实例目录:ListViewMultiDetailAppearance。
这个解决方案可以为MutliDetailItemAppearance创建自己的类,并根据需要注册很多细节(在我的情况下,我需要额外的8我想)。



现在我的问题:


  1. 这是最好的方法吗?

  2. 如果没有,什么是更好的方法如果是,如何添加额外的8个细节会影响
    的表现?

  3. ,最重要的是如何达到自定义着色元素
    每个列表视图项目基于值?

  4. 最后如何达到这个部分边框?和列表项目底部
    边界(绿线)?

提前非常感谢您的想法。 p>

解决方案

我不知道我的方式是否正确,但是我在fmx项目中使用了TListbox来达到目的。在 DataSource 通过 LiveBindings 填充之前,以下列方式形成其项目的结构。

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

with TPanel.Create(AEditor.CurrentObject as TMetropolisUIListBoxItem)do
begin
父级:=(AEditor.CurrentObject as TMetropolisUIListBoxItem);
对齐:= TAlignLayout.alRight;
宽度:= 45;
Margins.Bottom:= 1;
Margins.Top:= 1;
结束

与TLabel.Create((AEditor.CurrentObject as TMetropolisUIListBoxItem)
.Children.Items [2] as TPanel)do
begin
父级:=(AEditor。 CurrentObject as TMetropolisUIListBoxItem)
.Children.Items [2] as TPanel;
文字:='↓';
VertTextAlign:= TTextAlign.taCenter;
TextAlign:= TTextAlign.taCenter;
对齐:= TAlignLayout.alClient;
HitTest:= true;
AutoSize:= false;
StyledSettings:= StyledSettings - [TStyledSetting.ssStyle];
Font.Style:= Font.Style + [TFontStyle.fsBold];
标签:= HDM2.FDQicd_detail_for_TreeView.FieldByName('id')。AsInteger;
TagString:= HDM2.FDQicd_detail_for_TreeView.FieldByName
('category_etiology')AsString;
OnClick:= LabelInListBox1Click;
结束
结束



结束;
结束

此代码给了我以下Appearence:



您可以创建并嵌套所有必需的 TLayouts TLabels 等等,并使用 LiveBindings 事件处理程序内的逻辑设置所有必要的设置。


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.

解决方案

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.

这篇关于FireMoneky TListView项目中太多元素的最佳策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆