Not sure exactly what you mean, but you can process the OnDrawCell event to accomplish whatever kind of formatting you need.
The essential bits are passed in to the event handler in the parameter list:
Code:
if NeedToFormatThisCell( ACol, ARow ) then
with TStringGrid(Sender) do
FormatMyWay( Canvas, Rect, Cells[ACol,ARow] );
and you can create your own functions to support that construct.
Code:
function NeedToFormatThisCell( ACol, ARow: integer): boolean;
begin
// If this cell needs formatting, return True
// otherwise return False
end;
and
Code:
procedure FormatMyWay( ACanvas:TCanvas; ARect:TRect; AText:string );
begin
// Position the text within the rect on the canvas.
end;
For example, I have a routine that checks for a #13#10 in the text. If #13#10 is found, then the text is displayed on two lines inside a TRect. If not then the text is displayed centered vertically inside a TRect.
The trick is to define your own TRect in terms of left,right,top, and bottom (derived from the left,right,top, and bottom of the original TRect) and then use the .TextRect method of the TCanvas to position the text. The .TextWidth property of the TCanvas is also useful for horizontal alignment calculations.
Thanks for the tips, but I found a workaround for my problems.
Just used a StringGrid, some splitters and a CheckListBox to represent the top row of the string. Saved space since the stringgrid can be at 20 x 45 cells
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.