FireMoneky TListView项目中太多元素的最佳策略 [英] Best strategy for too many Elements in FireMoneky TListView Item
问题描述
我的任务是将ListView连接到ListView项目具有以下结构的数据集:
请记住,
- 元素4,6,& 8是固定值&颜色(即标签)
- 元素的颜色1& 10取决于元素5,7和& 9
最好的是引用Delphi标准示例,用Embarcadero Delphi实例目录:ListViewMultiDetailAppearance。
这个解决方案可以为MutliDetailItemAppearance创建自己的类,并根据需要注册很多细节(在我的情况下,我需要额外的8我想)。
现在我的问题:
- 这是最好的方法吗?
- 如果没有,什么是更好的方法如果是,如何添加额外的8个细节会影响
的表现? - ,最重要的是如何达到自定义着色元素
每个列表视图项目基于值? - 最后如何达到这个部分边框?和列表项目底部
边界(绿线)?
提前非常感谢您的想法。 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
- Elements 4, 6, & 8 are of fixed values & Color (i.e. labels)
- 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:
- Is this the best approach?
- if not, what is the better approach?
- if it is, how adding additional 8 details will affect the performance?
- and most important how to reach custom coloring for elements for each List View Item based on the values?
- 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屋!