How to display a multiline text in a StringGrid Cell (Delphi XE6 - Android)

Ro3000

I have a database bind to a Firemonkey StringGrid and I want to show a long text field in the cells, for an Android App, but I can't find a property nor procedure to do that. Any idea? (Thanks)

Ro3000

I've found a partial solution to this issue at this link:

http://fire-monkey.ru/topic/287-izmenenie-svoistva-shrifta-odnoi-iacheiki-v-firemonkey-tstringgrid-delphi-xe6/#entry1041

In the STringGrid's OnDrawColumnCell event (with a little modifications from the original), put this code:

procedure TForm1.StringGrid1DrawColumnCell(Sender: TObject; const Canvas: TCanvas; const Column: TColumn; const Bounds: TRectF; const Row: Integer; const Value: TValue; const State: TGridDrawStates);
const
   HorzTextMargin = 2;
   VertTextMargin = 1;
var
   TextLayout : TTextLayout;
   TextRect: TRectF;
begin
   // Here we determine which cell will redraw 
   if (Column.Index=0) then
   begin
      TextRect := Bounds;
      TextRect.Inflate(-HorzTextMargin, -VertTextMargin);
      Canvas.FillRect(Bounds, 0, 0, AllCorners, 1);
      TextLayout := TTextLayoutManager.DefaultTextLayout.Create;
      try
         TextLayout.BeginUpdate;
         try
            TextLayout.WordWrap := True; // True for Multiline text 
            TextLayout.Opacity := Column.AbsoluteOpacity;
            TextLayout.HorizontalAlign := StringGrid1.TextSettings.HorzAlign;
            TextLayout.VerticalAlign := StringGrid1.TextSettings.VertAlign;
            TextLayout.Trimming := TTextTrimming.Character;
            TextLayout.TopLeft := TextRect.TopLeft;
            TextLayout.Text := Value.ToString;
            TextLayout.MaxSize := PointF(TextRect.Width, TextRect.Height);

            { Custom settings rendering }
            TextLayout.Font.Family := 'Times New Roman';
            TextLayout.Font.Style := [ TFontStyle.fsBold ];
            TextLayout.Font.Size := 14;
            TextLayout.Color := claBlueViolet;
         finally
            TextLayout.EndUpdate;
         end;
         TextLayout.RenderLayout(Canvas);
      finally
         TextLayout.Free;
      end;
   end;
end;

We need to add 'Uses FMX.TextLayout;' to the form and 'System.UIConsts' for the color's constants.

To see a multiline text, of course we need to use a bigger number in the StringGrid's RowHeight property.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to display a multiline text in a StringGrid Cell (Delphi XE6 - Android)

From Dev

How to strike text in stringgrid (delphi)

From Dev

How to strike text in stringgrid (delphi)

From Dev

How to move cursor position in Delphi StringGrid cell?

From Dev

Delphi XE6 and Android Ping

From Dev

Delphi XE6 and Android Ping

From Dev

Component to display multiline text in Delphi

From Dev

How can I show an INFOR form before an INputquery in Delphi XE6 for Android

From Dev

Delphi XE6/Firemonkey - get the actual Text Height?

From Dev

Uploading a text file to cloud with Baas using Delphi XE6

From Dev

Application isn't responding - Delphi XE6 - Android

From Dev

How to pass and return a Stream using DataSnap in Delphi XE6?

From Dev

How to change font size of Delphi XE6 IDE

From Dev

How to Create DLL in C# and call in Delphi XE6

From Dev

How to pass and return a Stream using DataSnap in Delphi XE6?

From Dev

Delphi XE6: How to enumerate RCData resource names?

From Dev

How to get Application id(package + modulename) delphi XE5/XE6/XE7

From Dev

How to check iOS version delphi xe5/xe6

From Dev

Does supported android apps in Delphi XE6 with Qualcomm-Snapdragon-800-MSM8974?

From Dev

Delphi XE6 How to change the highlighting color of a TMetropolisUIListBoxItem using style

From Dev

Multiline text in DataGridView Cell

From Dev

how to display multiline text retrived from db

From Dev

Delphi (XE6) : Array of Byte to TStringList

From Dev

Delphi XE6 post request and indy

From Dev

Delphi XE6 Indy Chat Room

From Dev

Delphi xe6 - Database Login (Informix)

From Dev

Delphi XE6 Firemonkey Form

From Dev

How to make TMaskEdit a multiline edit in Delphi XE2

From Dev

macro for Multiline text in cell to truncate

Related Related

  1. 1

    How to display a multiline text in a StringGrid Cell (Delphi XE6 - Android)

  2. 2

    How to strike text in stringgrid (delphi)

  3. 3

    How to strike text in stringgrid (delphi)

  4. 4

    How to move cursor position in Delphi StringGrid cell?

  5. 5

    Delphi XE6 and Android Ping

  6. 6

    Delphi XE6 and Android Ping

  7. 7

    Component to display multiline text in Delphi

  8. 8

    How can I show an INFOR form before an INputquery in Delphi XE6 for Android

  9. 9

    Delphi XE6/Firemonkey - get the actual Text Height?

  10. 10

    Uploading a text file to cloud with Baas using Delphi XE6

  11. 11

    Application isn't responding - Delphi XE6 - Android

  12. 12

    How to pass and return a Stream using DataSnap in Delphi XE6?

  13. 13

    How to change font size of Delphi XE6 IDE

  14. 14

    How to Create DLL in C# and call in Delphi XE6

  15. 15

    How to pass and return a Stream using DataSnap in Delphi XE6?

  16. 16

    Delphi XE6: How to enumerate RCData resource names?

  17. 17

    How to get Application id(package + modulename) delphi XE5/XE6/XE7

  18. 18

    How to check iOS version delphi xe5/xe6

  19. 19

    Does supported android apps in Delphi XE6 with Qualcomm-Snapdragon-800-MSM8974?

  20. 20

    Delphi XE6 How to change the highlighting color of a TMetropolisUIListBoxItem using style

  21. 21

    Multiline text in DataGridView Cell

  22. 22

    how to display multiline text retrived from db

  23. 23

    Delphi (XE6) : Array of Byte to TStringList

  24. 24

    Delphi XE6 post request and indy

  25. 25

    Delphi XE6 Indy Chat Room

  26. 26

    Delphi xe6 - Database Login (Informix)

  27. 27

    Delphi XE6 Firemonkey Form

  28. 28

    How to make TMaskEdit a multiline edit in Delphi XE2

  29. 29

    macro for Multiline text in cell to truncate

HotTag

Archive