Hi guys!
I'm currently exploring lazarus and stumbled upon this code which I can't resolve and would like to ask for your guidance.
I can't figure out how to right align text in a column inside TStringGrid.DrawCell proc. Maybe I just missed something.
Here's a snippet
procedure TfrmChart.sgChartDrawCell(Sender : TObject; aCol, aRow : Integer;
aRect : TRect; aState : TGridDrawState);
var
fBalance : extended = 0;
rAlign: TTextStyle;
begin
if aRow > 0 then
begin
if (aCol = 1) and (sgChart.Cells[2,aRow] = 'GL') then
with sgChart do
begin
Canvas.Font.Style := [fsBold];
Canvas.FillRect(aRect);
Canvas.TextOut(aRect.Left + 2, aRect.Top + 2, Cells[aCol,aRow]);
end;
if (aCol = 3) then
with sgChart do
begin
rAlign := Canvas.TextStyle;
rAlign.Alignment := taRightJustify;
Canvas.TextStyle := rAlign;
Canvas.FillRect(aRect);
fBalance := StrToFloat(Cells[aCol,aRow]);
if fBalance < 0 then Canvas.Font.Color := clRed;
Canvas.TextOut(aRect.Left + 2, aRect.Top + 2, FormatFloat('#,##0.00;(#,##0.00)',fBalance));
end;
end;
end;
Additional:
Windows 7 Ultimate 32bit
lazarus 1.1 SVN 36782
Thank's a lot =)