简体   繁体   English

删除 Delphi FMX 上 TListView 的分隔线

[英]Remove separator lines for TListView on Delphi FMX

Is it possible to remove the separator lines in the TListView?是否可以删除 TListView 中的分隔线? I have tried playing with the properties on TListView but still unable to remove the lines on it... Can anyone helped on this?我尝试过使用 TListView 上的属性,但仍然无法删除它上面的线条......有人可以帮忙吗?

在此处输入图像描述

Have you tried using the "DynamicAppearance" mode?您是否尝试过使用“DynamicAppearance”模式? but you will have to write the code manually, add an image and a text field in the "Structure" section, and manage everything in the "onUpdateObjects" event.但是您必须手动编写代码,在“结构”部分添加图像和文本字段,并在“onUpdateObjects”事件中管理所有内容。 Like this:像这样:

procedure TForm1.FormCreate(Sender: TObject);
  var Voce : TListViewItem;
begin
      Voce := ListView1.Items.Add;
      Voce.Data['Text3'] := 'pippo 1';

      Voce := ListView1.Items.Add;
      Voce.Data['Text3'] := 'pippo 2';          
end;

procedure TForm1.ListView1UpdateObjects(const Sender: TObject;
                                    const AItem: TListViewItem);
  var ImageItem : TListItemImage;
      TextItem1 : TListItemText;
begin
      ImageItem := AItem.Objects.DrawableByName('Image2') as TListItemImage;
      TextItem1 := AItem.Objects.DrawableByName('Text3') as TListItemText;

      If Assigned(ImageItem) Then
         Begin
         ImageItem.Bitmap := ImageList1.Bitmap(TSizeF.Create(16,16),0);
         //ImageItem.PlaceOffset.X := 0;
         //ImageItem.PlaceOffset.Y := 0;
         End;

      If Assigned(TextItem1) Then
         Textitem1.TextColor := claRed;
end;

In "ImageList1" there is a simple white image.在“ImageList1”中有一个简单的白色图像。

Maybe it's possible to act on "Custom Style" to obtain the effect you want, but I am not capable of it, for other reasons I have used this procedure which, probably, will serve your purpose.也许可以对“自定义样式”进行操作以获得您想要的效果,但我无法做到,由于其他原因,我使用了这个程序,它可能会满足您的目的。 I have done some tests and it works quite well.我做了一些测试,效果很好。

Put a ListView on the form.在表单上放置一个 ListView。

In the section "Object Inspector": ItemApperance\ItemEditAppearance\DynamicAppearance ItemSpaces Left=0, Right=-10在“对象检查器”部分:ItemApperance\ItemEditAppearance\DynamicAppearance ItemSpaces Left=0, Right=-10

In the section "Structure": right click on "ListView1" and then "Toggle DesignMode" expand "ListView1" and select "Item", in the properties click on "Addnew...\TImageObjectAppearance"在“结构”部分:右键单击“ListView1”,然后“切换设计模式”展开“ListView1”和 select“项目”,在属性中单击“添加新...\TImageObjectAppearance”

the image will contain a white bitmap (or other color) that will cover the signs between one item and another, on the form you see the structure of the item, you can manually modify the image as you wish, or write in the "onUpdateObjects" event some code, here is an example:该图像将包含一个白色 bitmap(或其他颜色),它将覆盖一个项目和另一个项目之间的标志,在您看到项目结构的表格上,您可以根据需要手动修改图像,或写在“onUpdateObjects " 事件一些代码,这里是一个例子:

procedure TForm1.ListView1UpdateObjects(const Sender: TObject;
                                    const AItem: TListViewItem);
  var ImageItem : TListItemImage;
      TextItem1 : TListItemText;
begin
      ImageItem := AItem.Objects.DrawableByName('Image2') as TListItemImage;
      TextItem1 := AItem.Objects.DrawableByName('Text1') as TListItemText;

      //ImageItem.Bitmap := Image1.Bitmap;
      ImageItem.Bitmap := ImageList1.Bitmap(TSizeF.Create(16,16),0);
      //ImageItem.Visible := True;
      //ImageItem.ScalingMode := TImageScalingMode.Stretch;

      ImageItem.PlaceOffset.Y := -1;
      ImageItem.PlaceOffset.X := 0;
      ImageItem.Height := 2;
      ImageItem.Width := Width;
end;

To add items to the list, you need to use this code:要将项目添加到列表中,您需要使用以下代码:

var Voce : TListViewItem;
begin
      Voce := ListView1.Items.Add;
      Voce.Data['Text1'] := 'pippo 1';

Change the ListviewStyle.Frame.color property and set it equal to ListviewStyle.background.color property.更改 ListviewStyle.Frame.color 属性并将其设置为等于 ListviewStyle.background.color 属性。

Many ways to accomplish this:很多方法可以做到这一点:

  • Change default style更改默认样式
  • Modify the custom style修改自定义样式
  • Coding (but that's another challenge)编码(但这是另一个挑战)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM