Показать сообщение отдельно
  #3  
Старый 11.12.2012, 08:34
bambooshoot bambooshoot вне форума
Прохожий
 
Регистрация: 20.03.2011
Сообщения: 30
Репутация: 10
По умолчанию

Спасибо дружище!
Сделал так:
Код:
unit Unit1;

interface

uses
  ..... WinProcs, .....;

......
private
    procedure GridsDrawCell(Sender: TObject; ACol,
                 ARow: Integer; Rect: TRect; State: TGridDrawState);

procedure TForm1.GridsDrawCell(Sender: TObject; ACol,
  ARow: Integer; Rect: TRect; State: TGridDrawState);
 var
  StringGrid : TStringGrid;
  Format: Word;
  C : array[0..255] of Char;
  temp, max, i, j : integer;
begin
  if not (Sender is TStringGrid) then Exit;
  StringGrid := Sender as TStringGrid;
Format := DT_Center OR DT_WORDBREAK;
  (StringGrid).Canvas.FillRect(Rect);
  StrPCopy(C, (StringGrid).Cells[ACol, ARow]);
  WinProcs.DrawText((StringGrid).Canvas.Handle, C, StrLen(C), Rect, Format);
   for I := 0 to StringGrid.ColCount - 1 do
        begin
          max:= 0;
           for J := 0 to StringGrid.RowCount - 1 do
             begin
               temp := StringGrid.Canvas.TextWidth(StringGrid.Cells[i, j]);
                if temp > max then
                  max:=temp;
             end;
             StringGrid.ColWidths[i] := max + StringGrid.GridLineWidth + 10;
        end;
end;

procedure TForm1.FormCreate(Sender: TObject);
  StringGrid1.OnDrawCell:= GridsDrawCell;
     StringGrid2.OnDrawCell:= GridsDrawCell;
       ..............
Всем удачи
Ответить с цитированием