Have you tried using the "DynamicAppearance" mode? 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. 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.
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.
In the section "Object Inspector": 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"
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:
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.
Many ways to accomplish this:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.