Osnovni DBGrid koji stize uz Delphi ne reaguje adekvatno na skrol taster misa. Mozes da nasledis TDBGrid i dodas:
u protected:
function DoMouseWheelDown(Shift: TShiftState; MousePos: TPoint): Boolean; override;
function DoMouseWheelUp(Shift: TShiftState; MousePos: TPoint): Boolean; override;
u published :
property OnMouseWheelDown;
property OnMouseWheelUp;
Evo i koda za gornje funkcije:
Code:
function TTvojDBGrid.DoMouseWheelDown(Shift: TShiftState; MousePos: TPoint): Boolean;
begin
Result := False;
if Assigned(OnMouseWheelDown) then
OnMouseWheelDown(Self, Shift, MousePos, Result);
if not Result then begin
if not AcquireFocus then Exit;
if Datalink.Active then begin
Result := Datalink.DataSet.MoveBy(1) <> 0;
end;
end;
end;
function TTvojDBGrid.DoMouseWheelUp(Shift: TShiftState; MousePos: TPoint): Boolean;
begin
Result := False;
if Assigned(OnMouseWheelUp) then
OnMouseWheelUp(Self, Shift, MousePos, Result);
if not Result then begin
if not AcquireFocus then Exit;
if Datalink.Active then begin
Result := Datalink.DataSet.MoveBy(-1) <> 0;
end;
end;
end;