데이터베이스를 Firemonkey StringGrid에 바인딩하고 셀에 Android 응용 프로그램의 긴 텍스트 필드를 표시하고 싶습니다. 그것을 할 수있는 재산이나 절차를 찾지 못합니다. 어떤 생각? 나는이 링크에서이 문제에 대한 부분적인 해결책을 찾았StringGrid 셀에 여러 줄 문자를 표시하는 방법 (Delphi XE6 - Android)
1
A
답변
2
(감사) : (원래부터 약간의 수정을)를 STringGrid의 OnDrawColumnCell 이벤트에서
,이 코드를 넣어 :
를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;
'Use FMX.TextLayout;'을 추가해야합니다. 양식에 'System.UIConsts'를 지정합니다.
물론 여러 줄 텍스트를 보려면 StringGrid의 RowHeight 속성에서 더 큰 숫자를 사용해야합니다.
VCL on WIN32에도이 기능을 사용할 수 있습니까? –