在Firemonkey中实现ListView

介绍 (Introduction) 如果您像我发现没有TListview时那样对FireMonkey感到沮丧,请举手。 我在几乎所有已编写的应用程序中都使用了TListView,并且我not going to compromise by resorting to TStringGrid. By the 4th update to Delphi XE2 an...
摘要由CSDN通过智能技术生成

介绍 (Introduction)

如果您像我发现没有TListview时那样对FireMonkey感到沮丧,请举手。 我在几乎所有已编写的应用程序中都使用了TListView,并且我 not going to compromise by resorting to TStringGrid.

By the 4th update to Delphi XE2 and FireMonkey, I was ready to give up but then I stumbled on a video created by Marco Cantù which introduced me a bit more to FireMonkey and the fact that all visual objects are derived from TLayout - and more importantly - are Styleable.  He showed how one can change the style of any object to make changes to the base object to make it appear different - like adding a picture to a TListBoxItem.

在Delphi XE2和FireMonkey的第4次更新中,我准备放弃了,但是后来我偶然发现了MarcoCantù创建的视频,它向我介绍了FireMonkey以及更多的视觉对象均来自TLayout的事实-更重要的是-很时尚。 他展示了如何更改任何对象的样式以对基础对象进行更改以使其看起来与众不同,例如将图片添加到TListBoxItem。

I am now going to impart some of this knowledge to you.

我现在要向您介绍一些此类知识。

TListView的替代 (TListView's replacement)

正如我已经提到的,TListView在FireMonkey中不作为可视组件存在-我们现在有了TListBox。 如果我们继续创建新的FireMonkey HD应用程序,则在窗体上添加一个TListBox,然后双击它,我们将打开Items Designer。 现在我们可以添加项目,您将看到Items属性是TListBoxItem的集合
Items Designer
Listbox On Form

Essentially, what we are going to do is change the Style of the ListBoxItem so that it includes a lot more than just one text field, and then when we add items to the listbox at run time, we're going to tell it to use our new style.

本质上,我们要做的是更改ListBoxItem的样式,以便它不仅包含一个文本字段,而且还包含许多其他内容,然后在运行时将项目添加到列表框中时,我们将告诉它使用我们的新风格。

样式样式 (Styling the Style)

在表单上使用可怕的模板时,右键单击放置的ListBoxItem,然后选择“编辑自定义样式...”
Edit Custom Style

Automatically, a new TStyleBook object named StyleBook1 will be added to your project, and you will be taken to the Style Layout screen as shown below.

自动将一个名为StyleBook1的新TStyleBook对象添加到您的项目中,然后将您转到“样式布局”屏幕,如下所示。

Style Window

You will notice that it has added two styles for you.  CheckBoxStyle and ListBoxItemstyle.  The reason you have two (even though you only selected one) is because CheckBoxStyle is a style used by ListBoxItem's check, so it related styles to your stylebook.  We're going to ignore the CheckBoxStyle for now (it won't ever get used), and concentrate on the ListBoxItemStyle.

您会注意到它为您添加了两种样式。 CheckBoxStyle和ListBoxItemstyle。 之所以拥有两个(即使您只选择了一个),是因为CheckBoxStyle是ListBoxItem的检查使用的样式,因此它将样式与样式簿相关联。 现在,我们将忽略CheckBoxStyle(将永远不会使用它),而将重点放在ListBoxItemStyle上。

If you expand ListBoxItemstyle, it will select it and show it you on screen, as well as show you the two children text: TTex

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ModernListView (Berlin, Tokyo [with fix], Rio) 很好的Delphi Firemonkey控件,可用作Android、iOS、MacOS、Windows开发,比Delphi自带的listview更好用、功能更强大! ListView1.SetColorItemSelected(TAlphaColorRec.Orangered); ListView1.SetColorItemFill(TAlphaColorRec.Whitesmoke); ListView1.SetColorItemFillAlt(TAlphaColorRec.Lightgrey); ListView1.SetColorBackground(TAlphaColorRec.Whitesmoke); ListView1.SetColorItemSeparator(TAlphaColorRec.Red); ListView1.SetColorText(TAlphaColorRec.Darkmagenta); ListView1.SetColorTextSelected(TAlphaColorRec.Blueviolet); ListView1.SetColorTextDetail(TAlphaColorRec.Darksalmon); ListView1.SetColorHeader(TAlphaColorRec.Crimson); ListView1.SetColorTextHeader(TAlphaColorRec.Whitesmoke); ListView1.SetColorTextHeaderShadow(TAlphaColorRec.grey); ListView1.SetColorPullRefresh(TAlphaColorRec.Lime); ListView1.SetColorPullRefreshIndicator(TAlphaColorRec.Limegreen); ListView1.SetColorStretchGlow(TAlphaColorRec.Limegreen); Style for ListView Columns Mode ListView1.ShowScrollBar - hide/show scrollbar ListView1.ItemsClearTrue - correct delete items ListView1.OffsetTop - indent of the first element ListView1.OffsetBottom - indent of the last element ListView1.getFirstVisibleItemIndex - first visible ItemIndex ListView1.getVisibleCount - amount of visible items ListView1.getLastVisibleItemindex - first visible ItemIndex + amount of visible items ListView1.SeparatorLeftOffset - indent for separator line ListView1.SeparatorRightOffset - indent for separator line ListView1.EnableTouchAnimation - enable/disable touch animation

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值