Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure TForm1.AutoSizeDBGrid(const xDBGrid: TDBGrid);
- var
- I, TotalWidht, VarWidth, QtdTotalColuna : Integer;
- xColumn : TColumn;
- begin
- TotalWidht :=0;
- VarWidth :=0;
- QtdTotalColuna := 0;
- for I:=0 to -1 + xDBGrid.Columns.Count do
- begin
- TotalWidht := TotalWidht + xDbGrid.Columns[I].Width;
- Inc(QtdTotalColuna);
- end;
- if QtdTotalColuna = 0 then
- Exit;
- if not (TotalWidht < xDBGrid.ClientWidth) then
- Exit;
- if dgColLines in xDBGrid.Options then
- TotalWidht := TotalWidht + xDBGrid.Columns.Count;
- if dgIndicator in xDBGrid.Options then
- TotalWidht := TotalWidht + IndicatorWidth;
- VarWidth := xDBGrid.ClientWidth - TotalWidht;
- if QtdTotalColuna > 0 then
- VarWidth := VarWidth div QtdTotalColuna;
- for I:=0 to -1 + xDBGrid.Columns.Count do
- begin
- xDBGrid.Columns[I].Width:=xDBGrid.Columns[I].Width+VarWidth;
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement