Автор: infomSB
Дата сообщения: 27.10.2008 09:10
Kmich
Просто так это не сделать, необходимо писать свой обработчик прорисовки Caption колонок, я делал так:
procedure TfrmMain.cxGrid1TableView1CustomDrawColumnHeader(
Sender: TcxGridTableView; ACanvas: TcxCanvas;
AViewInfo: TcxGridColumnHeaderViewInfo; var ADone: Boolean);
var
Size: TSize;
OldFont: TLogFont;
LogFont: TLogFont;
ARect: TRect;
I, RCount, Offset, StrLen, YOut: Integer;
AClipRegion: TcxRegion;
PartText, RestText:String;
begin
with AViewInfo do
begin
GetObject(ACanvas.Font.Handle, SizeOf(OldFont), @OldFont);
LogFont := OldFont;
with LogFont do
begin
lfEscapement := 900;
lfOrientation := lfEscapement;
lfOutPrecision := OUT_TT_ONLY_PRECIS;
end;
ACanvas.Font.Handle := CreateFontIndirect(LogFont);
GetTextExtentPoint32(ACanvas.Handle, PChar(Text), Length(Text), Size);
ARect := Bounds;
PartText := '';
RestText := Text;
LookAndFeelPainter.DrawHeader(ACanvas, Bounds, TextAreaBounds,
Neighbors, Borders, cxbsNormal, taCenter, vaCenter, False, False, '',
ACanvas.Font, clNone, Params.Color);
with TextAreaBounds do
if Left < Right then
begin
RCount := (Size.cx div (Bottom - Top - 2))+1;
RestText := WrapText(RestText, '@',[' '], Length(RestText) div RCount);
Offset := (Right - Left - Size.cy*RCount) div 2;
for I := 1 to RCount do // Iterate
begin
StrLen := pos('@', RestText);
if StrLen < 1 then StrLen := Length(RestText);
PartText := StringReplace(copy(RestText, 1, StrLen), '@', '', [rfReplaceAll]);
RestText := copy(RestText, StrLen+1, Length(RestText)-StrLen);
GetTextExtentPoint32(ACanvas.Handle, PChar(PartText), Length(PartText), Size);
if Size.cx < Bottom - Top - 2 then
YOut := Bottom - ((Bottom - Top - 2 - Size.cx) div 2)
else YOut := Bottom - 1;
ACanvas.Canvas.TextOut((Left+Offset+(I-1)*Size.cy),
(YOut),
PartText)
end; // for
end;
AClipRegion := ACanvas.GetClipRegion;
try
for i := 0 to AreaViewInfoCount - 1 do
AreaViewInfos[i].Paint;
finally
ACanvas.SetClipRegion(AClipRegion, roSet);
end;
ADone := True;
AViewInfo.Column.BestFitMaxWidth := (RCount+1)*Size.cy;
end;
end;
Взято кстати с этого топика )