TIP: Click on subject to list as thread! ANSI
echo: delphi
to: JOAQUIM HOMRIGHAUSEN
from: FRANK MALCOLM
date: 1997-11-25 04:51:00
subject: D1: TStringGrid cell alig

Hi, Joaquim.
JH>   Is there a way to change the alignment of data that appears in a
JH> TStringGrid cell? I'm using a TSG (instead of a Listbox) to display a 
numbe
JH> of records from a binary file and want to right-align the display of some 
o
JH> the cells.. ?
I do it by setting the style to OwnerDraw, then in the OnDrawCell
event I have
if Col in [0, 2, 3, 5..10] then
  Left := Rect.Right -
          Entrant.Canvas.TextWidth (Entrant.Cells[Col, Row]) - 2
else
  Left := Rect.Left + 2;
Entrant.Canvas.TextOut (Left, Rect.Top, Entrant.Cells[Col, Row]);
Which right-justifies the specified columns and left-justifies the rest,
allowing 2 pixels from the border in each case.
Regards, fIM.
---
 þ * þ þ It's time for SCREAMING WITH BINKY!
---
---------------
* Origin: Pedants Inc. (3:712/610.24)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.