• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Delphi7取消StringGrid的自动滚动

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

StringGrid的Options的goRowSelect为false时,在点击右侧未显示完全的Cell,StringGrid会自动向左滚动,怎样设定,取消StringGrid的自动滚动啊?Delphi7版的


 

终于自己找到解决办法了:
拷贝Grids.pas到自己项目的目录,并通过Project Manager加入到自己工程项目中
修改 
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要自动滚动,另一个StringGrid不要自动滚动的办法:

mianform.pas
 
procedure TForm1.FormCreate(Sender: TObject);
  StringGrid1.CanAutoMove:=False;
  StringGrid4.CanAutoMove:=True;
 

grids.pas
  TCustomGrid = class(TCustomControl)
  public
     {+} CanAutoMove   : Boolean ;   //涂磊+20161123
     
procedure TCustomGrid.MoveCurrent(ACol, ARow: Longint; MoveAnchor
 
    if ( Show) and (CanAutoMove) then ClampInView(FCurrent);   //{*}涂磊20161123

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Delphi类成员的默认访问权限(用RTTI检测)发布时间:2022-07-18
下一篇:
GifImage2.2控件下载forDelphi7/6发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap