Is there a way to move the contents of the TDBGrid
as you drag the vertical scrollbar thumb button (instead of only moving the contents once released)?
I found something called ScrollTrack
property for a DBGrid
but I guess that is .Net? Is there something like that for Delphi/C++Builder? Or a way to have it scroll the contents as the thumb button is dragged?
TIA!!
You can do this with an Interposer Class.
Create a new unit with this content:
unit DBGridHelper;
interface
uses
Winapi.Messages, Winapi.Windows,
Vcl.DBGrids;
type
TDBGrid = class(Vcl.DBGrids.TDBGrid)
private
procedure WMVScroll(var Message: TWMVScroll); message WM_VSCROLL;
end;
implementation
procedure TDBGrid.WMVScroll(var Message: TWMVScroll);
begin
inherited;
if not (Focused or (InplaceEditor <> nil) and InplaceEditor.Focused) then Exit;
if Datalink.Active then begin
case Message.ScrollCode of
SB_THUMBTRACK: DataLink.DataSet.RecNo := Message.Pos;
end;
end;
end;
end.
In each unit containing a TDBGrid that should have this behavior, you need to add this unit to the interface uses clause somewhere after Vcl.DBGrids.