There is an article describing how to customize TTMSFMXTableView to display items to have a nice Bubble message list by overriding the item shapes with the OnItemCustomize event.
Below is a small sample that demonstrates this.
1. How can I apply the same to TTMSFNCTableView?
2. How can I move the Item bitmap to be aligned left or right ?
Thanks
procedure TForm1.TMSFMXTableView1ItemCustomize(Sender: TObject;
AItem: TTMSFMXTableViewItem; AItemShape: TTMSFMXTableViewItemShape;
AItemControlShape: TControl);
begin
if Odd(AItem.Index) then
begin
AItemShape.Margins.Left := 50;
AItemShape.Fill.Color := TAlphaColorRec.Lime;
end
else
AItemShape.Margins.Right := 50;
AItemShape.Margins.Top := 5;
AItemShape.Align := TAlignLayout.Top;
AItemShape.Corners := AllCorners;
end;
Pieter
(Pieter)
April 27, 2020, 8:35pm
2
To get you started, please take a look at the following code:
procedure TForm26.FormCreate(Sender: TObject);
begin
TMSFNCTableView1.BeginUpdate;
TMSFNCTableView1.Fill.Color := gcLightgray;
TMSFNCTableView1.ItemAppearance.FixedHeight := 75;
TMSFNCTableView1.ItemAppearance.HeightMode := tvhmFixed;
TMSFNCTableView1.EndUpdate;
end;
procedure TForm26.TMSFNCTableView1BeforeDrawItem(Sender: TObject;
AGraphics: TTMSFNCGraphics; ARect: TRectF; AItem: TTMSFNCTableViewItem;
var AAllow, ADefaultDraw: Boolean);
var
r: TRectF;
begin
r := ARect;
InflateRectEx(r, -10, -10);
ADefaultDraw := False;
AGraphics.Fill.Kind := gfkSolid;
if Odd(AItem.Index) then
begin
AGraphics.Fill.Color := gcLime;
r.Right := r.Right - 30;
end
else
begin
AGraphics.Fill.Color := gcWhite;
r.Left := r.Left + 30;
end;
if AItem.IsSelected then
AGraphics.Fill.Color := gcSteelblue;
AGraphics.DrawRoundRectangle(r);
end;
procedure TForm26.TMSFNCTableView1BeforeDrawItemText(Sender: TObject;
AGraphics: TTMSFNCGraphics; ARect: TRectF; AItem: TTMSFNCTableViewItem;
AText: string; var AAllow: Boolean);
var
r: TRectF;
ha: TTMSFNCGraphicsTextAlign;
begin
r := ARect;
InflateRectEx(r, -10, -10);
AAllow := False;
if Odd(AItem.Index) then
ha := gtaTrailing
else
begin
r.Left := r.Left + 30;
ha := gtaLeading;
end;
if AItem.IsSelected then
AGraphics.Font.Color := gcWhite;
AGraphics.DrawText(r, AText, True, ha)
end;