首页 > 代码库 > 取消StringGrid的自动滚动
取消StringGrid的自动滚动
StringGrid的Options的goRowSelect为false时,在点击右侧未显示完全的Cell,StringGrid会自动向左滚动,怎样设定,取消StringGrid的自动滚动啊?Delphi7版的
终于自己找到解决办法了:
拷贝Grids.pas到自己项目的目录,
修改
procedure TCustomGrid.MoveCurrent(ACol, ARow: Longint; MoveAnchor,
Show: Boolean);
var
OldSel: TGridRect;
OldCurrent: TGridCoord;
begin
if (ACol < 0) or (ARow < 0) or (ACol >= ColCount) or (ARow >= RowCount) then
InvalidOp(SIndexOutOfRange);
if SelectCell(ACol, ARow) then
begin
OldSel := Selection;
OldCurrent := FCurrent;
FCurrent.X := ACol;
FCurrent.Y := ARow;
if not (goAlwaysShowEditor in Options) then HideEditor;
if MoveAnchor or not (goRangeSelect in Options) then
begin
FAnchor := FCurrent;
if goRowSelect in Options then FAnchor.X := ColCount - 1;
end;
if goRowSelect in Options then FCurrent.X := FixedCols;
// if Show then ClampInView(FCurrent); {-20161029 将这一行注释掉}
SelectionMoved(OldSel);
with OldCurrent do InvalidateCell(X, Y);
with FCurrent do InvalidateCell(ACol, ARow);
end;
end;
取消StringGrid的自动滚动