Right align in TStringGrid

I have a one-row TStringGrid, which has only two columns.

(I use a one-row TStringGrid here for appearance purposes, as it provides the total values for the rows in another TStringGrid that appears above it on my form.)

I want to right align the text.

When I run it, the first column shows both text and both left-aligned and right-aligned (e.g. 44.72    44.72), but the second column just shows the right-aligned text.

I can't work out how to get rid of the bogus left-aligned data.

Here is the code, which is fairly standard:

procedure TfTrans.sgTotalsDrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
  SavedAlign: Word;
  SaveString: string;
  with sgTotals do
    SavedAlign := SetTextAlign(Canvas.Handle, TA_RIGHT);
    SaveString := Cells[ACol,ARow];
      Rect.Right - 4, Rect.Top + 2, SaveString);
    SetTextAlign(Canvas.Handle, SavedAlign);

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Pierre CorneliusCommented:
Did you set the grid's defaultdrawing property to false?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GrahamDLovellAuthor Commented:
Setting the grid's default drawing property to false fixed the problem.

Pierre CorneliusCommented:
You're welcome.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.