我设置了表格的大小,现在一页只能显示17条记录,如果记录数比较多的时候要用滚动条翻动,很麻烦,于是根据字段做了一个简单的查询,用来定位记录,现在记录是能定位了,但是stringgrid的表格不跟着滚动,怎么能让表格跟着滚动呢?
17条之前的记录我能看到,后面的记录还是要手动取托滚动条~!
郁闷撒。不知道大家听明白我说的意思没?
    for i := 0 to sgdGXSJ.RowCount do
    begin
      if sgdGX.Cells[1, i] = str1 then
      begin
        myRect.Left := 0;
        myRect.Top := i;
        myRect.Right := 5;
        myRect.Bottom := i;
        sgdGX.Selection := myRect;
        if MessageDlg('查找下一个记录, mtconfirmation, [mbyes, mbno], 0) = mrno then
        begin
          sgdGX.SetFocus;
          Exit;
        end;
      end;
    end;

解决方案 »

  1.   

    sgdGXSJ.OnRowMoved?感觉要用到这个东西呢~!
      

  2.   


     for i := 0 to sgdGX.RowCount-1 do
      if sgdGX.Cells[1, i] = str1 then
      begin
        sgdGX.Row:=i;
        sgdGX.TopRow:=i;
        if MessageDlg('查找下一个记录, mtconfirmation, [mbyes, mbno], 0) = mrno then exit;
      end;奉上解答,请教了单位的前辈,佩服的五体投地~!
      

  3.   

    stringgrid 定位到一行记录之后,如果用鼠标滚轮操作滚动条的话,之前定位选中的记录位置会随着改变,如何不让记录的标记发生改变?同时还保留stringgrid的滚动条功能呢?是不是就是改个stringgrid的options设置,还是要在哪个事件写代码?
      

  4.   


    procedure TSJMain.ApplicationEvents1Message(var Msg: tagMSG;
      var Handled: Boolean);
    begin
      if (Msg.message = WM_MOUSEWHEEL) and (Msg.hwnd = sgdGXSJ.Handle) then begin
        SendMessage(sgdGXSJ.Handle, WM_VSCROLL, Byte(Msg.wParam<=0), 0);
        Handled := True;
      end;
    end;
      

  5.   

    在Additional组件页上,选择ApplicationEvents控件,在on message事件里面写如上代码。转自lihuasoft.谢谢