修改GRID.pas view plaincopy to clipboardprint? //在TCustomGrid.SetColWidths事件改为: procedure TCustomGrid.SetColWidths(Index: Longint; Value: Integer); begin if FColWidths = nil then UpdateExtents(FColWidths, ColCount, DefaultColWidth); if Index >= ColCount then InvalidOp(SIndexOutOfRange); if Value <> PIntArray(FColWidths)^[Index + 1] then begin if Value < 12 then Value := 30; //新增 ResizeCol(Index, PIntArray(FColWidths)^[Index + 1], Value); PIntArray(FColWidths)^[Index + 1] := Value; ColWidthsChanged; end; end; //在TCustomGrid.SetColWidths事件改为: procedure TCustomGrid.SetColWidths(Index: Longint; Value: Integer); begin if FColWidths = nil then UpdateExtents(FColWidths, ColCount, DefaultColWidth); if Index >= ColCount then InvalidOp(SIndexOutOfRange); if Value <> PIntArray(FColWidths)^[Index + 1] then begin if Value < 12 then Value := 30; //新增 ResizeCol(Index, PIntArray(FColWidths)^[Index + 1], Value); PIntArray(FColWidths)^[Index + 1] := Value; ColWidthsChanged; end; end; 修改DBGRID.pas view plaincopy to clipboardprint? //在procedure TCustomDBGrid.DrawCell事件中找到下面这一行 procedure TCustomDBGrid.DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState); begin //... FIndicators.Draw(Canvas, ALeft, (ARect.Top + ARect.Bottom - FIndicators.Height) shr 1, Indicator, True); if ACol <0 then begin Canvas.TextRect(ARect,0,(ARect.Top + ARect.Bottom - FIndicators.Height) shr 1 , inttostr(self.DataSource.DataSet.RecNo)); end; //新增 //..... end;