2014-11-09 7 views

답변

2

(감사) : (원래부터 약간의 수정을)를 STringGrid의 OnDrawColumnCell 이벤트에서

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

,이 코드를 넣어 :

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 속성에서 더 큰 숫자를 사용해야합니다.

+0

VCL on WIN32에도이 기능을 사용할 수 있습니까? –