Einzelnen Beitrag anzeigen

hoika

Registriert seit: 5. Jul 2006
Ort: Magdeburg
8.270 Beiträge
 
Delphi 10.4 Sydney
 
#3

Re: TStringGrid: optimale Breite einer Spalte

  Alt 20. Jul 2009, 16:02
Hallo,

ClientWidth ist 432, Grid.Width ist 436.
GridLineWidth ist 1 und wurde bereits berücksichtigt

iColWidth:= iColWidth-(theGrid.GridLineWidth*theGrid.ColCount);

OK, das sind 4 weniger.
Jetzt habe ich die 10 fest eingetragen und es klappt !!
Sollte das die ScrollBar sein ?


Delphi-Quellcode:
procedure Grid_SetOptimalWidth(theGrid: TStringGrid;
  const theColumn: Integer);
var
  iLeftWidth : Integer;
  iColWidth : Integer;
  iCol : Integer;
begin
  try
    iColWidth:= 0;
    for iCol:= 0 to theGrid.ColCount-1 do
    begin
      if iCol<>theColumn then
      begin
        iColWidth:= iColWidth+theGrid.ColWidths[iCol];
      end;
    end;
    iColWidth:= iColWidth-(theGrid.GridLineWidth*theGrid.ColCount);

    iLeftWidth:= theGrid.ClientWidth-iColWidth-10;

    theGrid.ColWidths[theColumn]:= iLeftWidth;
  except
  end;
end;
Heiko
  Mit Zitat antworten Zitat