Customizing TTMSFMXTableView and TTMSFMXTableView

Hello,


We have been banging our heads for the past month trying to reproduce some aspects of one of the samples of the documentation for TTMSFMXTableView and TTMSFMXTableView (TMS FMX UI Pack DEVELOPERS GUIDE the black sample on page 34).

Sorry I could not see how to add a screenshot to this post, but what I would like to do is to reproduce the following aspects of the sample on page 34:
  • Change the color of the Caption of each Item
  • Make the Caption and/or Description text WordWrap (multiline)
  • Change the background and text color of the TTMSFMXTableView and TTMSFMXTableView (basically we are stuck with the Grey background and white text).
We have searched all the documentation PDFs and the forum for a month and now we are ready to give up and ask for help.

Very best regards,

Olivier

The TTMSFMXTableView relies on styles to change the appearance. You can either modify the style, or change the appearance of the items at runtime. To change, for example, the caption color, you can use the following code:




procedure TForm1.TMSFMXTableView1ItemCustomize(Sender: TObject;
  AItem: TTMSFMXTableViewItem; AItemShape: TTMSFMXTableViewItemShape;
  AItemControlShape: TControl);
begin
  AItemShape.ShapeCaption.Color := TAlphaColorRec.Red;
end;


This way, you can customize all settings of each element that is displayed within an item.

For the background you can use the following code, in the OnApplyStyleLookup, where all elements are already properly initialized.



uses
  FMX.Objects;


procedure TForm1.TMSFMXTableView1ApplyStyleLookup(Sender: TObject);
var
  r: TRectangle;
begin
  r := (TMSFMXTableView1.GetListBackGround as TRectangle);
  r.Fill.Color := TAlphaColorRec.Red;
end;

Pieter Scheldeman2017-10-16 09:04:45

Thank you very much.

I am still not sure how to make the Caption and/or Description text WordWrap (multiline) ?

Hi, 


You can wordwrap in the same way as setting the color of the caption:



procedure TForm1.TMSFMXTableView1ItemCustomize(Sender: TObject;
  AItem: TTMSFMXTableViewItem; AItemShape: TTMSFMXTableViewItemShape;
  AItemControlShape: TControl);
begin
  AItemShape.ShapeCaption.WordWrap := True;
end;

Thank you very much.

How can I tell how many lines are added due to WordWrap so that I can make the Item higher ?
Or is there an "autoHeight" for the items ?

Hi, 


Yes, you can use the AutoSize property of an item.
This way, the wordwrapped text should automatically resize the item.

Thank you very much !