Недавно добавленные исходники

•  DeLiKaTeS Tetris (Тетрис)  4 796

•  TDictionary Custom Sort  6 793

•  Fast Watermark Sources  6 581

•  3D Designer  9 534

•  Sik Screen Capture  6 918

•  Patch Maker  7 365

•  Айболит (remote control)  7 303

•  ListBox Drag & Drop  6 168

•  Доска для игры Реверси  98 108

•  Графические эффекты  7 481

•  Рисование по маске  6 774

•  Перетаскивание изображений  5 630

•  Canvas Drawing  6 007

•  Рисование Луны  5 798

•  Поворот изображения  5 251

•  Рисование стержней  3 844

•  Paint on Shape  2 999

•  Генератор кроссвордов  3 955

•  Головоломка Paletto  3 138

•  Теорема Монжа об окружностях  3 969

•  Пазл Numbrix  2 620

•  Заборы и коммивояжеры  3 431

•  Игра HIP  2 347

•  Игра Go (Го)  2 264

•  Симулятор лифта  2 664

•  Программа укладки плитки  2 225

•  Генератор лабиринта  2 775

•  Проверка числового ввода  2 385

•  HEX View  2 720

•  Физический маятник  2 411

 
скрыть

Автоматический подбор ширины колонок для TStringGrid



Оформил: DeeCo

 procedure SetGridColumnWidths(Grid: TStringGrid;
   const Columns: array of Integer);
 { 
  When you double-Click on a Column-Header the Column 
  autosizes to fit its content 

  Bei Doppelklick auf eine fixierte Spalte passt sich 
  die Spaltenbreite der Textgrosse an 
}

   procedure AutoSizeGridColumn(Grid: TStringGrid; column, min, max: Integer);
     { Set for max and min some minimal/maximial Values}
     { Bei max and min kann eine Minimal- resp. Maximalbreite angegeben werden}
   var
     i: Integer;
     temp: Integer;
     tempmax: Integer;
   begin
     tempmax := 0;
     for i := 0 to (Grid.RowCount - 1) do
     begin
       temp := Grid.Canvas.TextWidth(Grid.cells[column, i]);
       if temp > tempmax then tempmax := temp;
       if tempmax > max then
       begin
         tempmax := max;
         break;
       end;
     end;
     if tempmax < min then tempmax := min;
     Grid.ColWidths[column] := tempmax + Grid.GridLineWidth + 3;
   end;

   procedure TForm1.StringGrid1DblClick(Sender: TObject);
   var
     P: TPoint;
     iColumn, iRow: Longint;
   begin
     GetCursorPos(P);
     with StringGrid1 do
     begin
       P := ScreenToClient(P);
       MouseToCell(P.X, P.Y, iColumn, iRow);
       if P.Y < DefaultRowHeight then
         AutoSizeGridColumn(StringGrid1, iColumn, 40, 100);
     end;
   end;