LeTay
asked on
Center text in a TStringGrid cell
Is it possible (and how) to center a text in TStringGrid cell ?
ASKER
The Display (..) does not compile (undeclared identifier)
Which version of delphi are you using?
Example works with D7.
Example works with D7.
have you tried a component like devexpress quantumgrid ?
it might be expensive, but it would allow you to set the text align = alCenter
for a column
it might be expensive, but it would allow you to set the text align = alCenter
for a column
ASKER
Delphi XE2
ASKER
Maybe some unit is missing in my uses clause ?
Here is my uses clause :
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids, StdCtrls, ExtCtrls, Buttons, Db, DBTables, Printers, ComCtrls;
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids, StdCtrls, ExtCtrls, Buttons, Db, DBTables, Printers, ComCtrls;
ASKER
I adapted but it does not compile
Can You click on that Display in your environment ?
It will show you the Display' unit
Thanks
Can You click on that Display in your environment ?
It will show you the Display' unit
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Many many thanks
You are welcome...
Thank's for points and grading :)
Thank's for points and grading :)
procedure TForm1.MyStringGridDrawCel
Rect: TRect; State: TGridDrawState);
begin
with (Sender as TStringGrid), Canvas do
begin
TextRect(Rect, Rect.Left + 2, Rect.Top + 2, Cells[Acol, Arow]);
FrameRect(Rect);
Display(MyStringGrid, MyStringGrid.Cells[ACol, ARow], Rect, taCenter); //taLeftJustify, taRightJustify
end;