yurrea
asked on
How To Align Real Values inside a StringGrid
How do you right-align real values inside columns of a StringGrid using Tahoma as font? .. Right now I encounter problems because what I do is add spaces in front of the text to move it to the right .. however, it doesn't work quite well .. the values seem to be in zigzag mode .. Is there something wrong with what I do? or is it because of the font? .. especially when there are commas (',') in the value. Is there a way to get around this problem?
Yvann
Yvann
ASKER
Jacco
I'll check it out.
Yvann
I'll check it out.
Yvann
This should give you an idea.
var
R1 : TRect;
begin
R1:=StringGrid1.CellRect(x , y)
DrawText(StringGrid1.Canva s.Handle, PChar(Text), -1, R1, DT_CALCRECT or DT_RIGHT or
DT_WORDBREAK or DT_NOPREFIX or DrawTextBiDiModeFlagsReadi ngOnly);
end;
Regards
Peter
var
R1 : TRect;
begin
R1:=StringGrid1.CellRect(x
DrawText(StringGrid1.Canva
DT_WORDBREAK or DT_NOPREFIX or DrawTextBiDiModeFlagsReadi
end;
Regards
Peter
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Jacco, PeterLarsen:
I can't seem to make your solutions work. :(
Sorry guys.
VSF:
This is what I'm looking for, and it works fine. :)
I can't seem to make your solutions work. :(
Sorry guys.
VSF:
This is what I'm looking for, and it works fine. :)
No worries - you'r problem is solved - thats what counts !!
I'm glad to help.
Please show your support visiting my homepages:
www.victory.hpg.com.br
www.enge.cbj.net
Thanks
VSF
UIN:14016999
Please show your support visiting my homepages:
www.victory.hpg.com.br
www.enge.cbj.net
Thanks
VSF
UIN:14016999
Yes the font is the problem if you use Courier as the font you wil not have this problem. You can either use a DrawGrid to overcome this problem (downside is that the drawgrid will not store data). Or you can use the OnDrawCell event of the TStringGrid.
In the OnDrawCell even you you can issue a Canvas.TextOut on the correct position. You can calculate the width of the string by calling Canvas.TextWidth(sYourStri
Regards Jacco