Delphi syntaxroperty AfterScroll: TDataSetNotifyEvent;C++ syntax:__property TDataSetNotifyEvent AfterScroll = {read=FAfterScroll, write=FAfterScroll};DescriptionWrite an AfterScroll event handler to take specific action immediately after an application scrolls to another record as a result of a call to the First, Last, MoveBy, Next, Prior, FindKey, FindFirst, FindNext, FindLast, FindPrior, and Locate methods. AfterScroll is called after all other events triggered by these methods and any other methods that switch from record to record in the dataset.// ----------------------------------------------------------你在 DBGrid 里鼠标滚动, 只是 DBGrid 的焦点行移动了, 但指向记录集里的当前记录位置并没改变!
dbgrid的确存在这个bug,在你的代码部分的type之后,Form定义之前,增加如下代码:TDbGrid=class(DBGrids.dbgrid)protected procedure MouseWheelHandler(var Message: TMessage); override;end;函数实体为:procedure TDbGrid.MouseWheelHandler(var Message: TMessage);begin inherited; if (DataLink.DataSet<>nil) then if DataLink.DataSet.State=dsBrowse then begin if (Message.WParam>0)and (Not DataLink.DataSet.Bof) then DataLink.DataSet.Prior else if (Message.WParam<0)and (Not DataLink.DataSet.Eof) then DataLink.DataSet.Next; Self.Repaint; end;end;-----------本人以前就是这样来处理这个问题的。
你加上行状态了没?procedure TForm1.dbgrd1DrawDataCell(Sender: TObject; const Rect: TRect; Field: TField; State: TGridDrawState);begin // 选中行或焦点行 if State * [gdSelected, gdFocused] <> [] then begin end else // 非固定行 if not (gdFixed in State) then begin end; // 固定行我们就不画了~end;