hrvica5
asked on
DBCtrlGrid, Delphi, Scroll
Hi,
How is it possible to scroll DBCtrlGrid in delphi2010?
Thx, Hr
How is it possible to scroll DBCtrlGrid in delphi2010?
Thx, Hr
ASKER
This is great and it works, but is it possible to force VK_UP, VK_DOWN scrolling.
I have problem for example I have few columns and if I scroll down my button goes on the dataset.next / DataSet.Prior, but I need next row.
Thank you
I have problem for example I have few columns and if I scroll down my button goes on the dataset.next / DataSet.Prior, but I need next row.
Thank you
procedure TForm1.FormMouseWheel(Send er: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
Begin
if not(PtInRect(DBCtrlGrid1.C lientRect, DBCtrlGrid1.ScreenToClient (MousePos) )) then
Exit;
if not Assigned(DBCtrlGrid1.DataS ource) then
Exit;
if DBCtrlGrid1.DataSource.Dat aSet = nil then
Exit;
if WheelDelta > 0 then
DBCtrlGrid1.DataSource.Dat aSet.prior
else
DBCtrlGrid1.DataSource.Dat aSet.next;
Handled := True;
end;
Begin
if not(PtInRect(DBCtrlGrid1.C
Exit;
if not Assigned(DBCtrlGrid1.DataS
Exit;
if DBCtrlGrid1.DataSource.Dat
Exit;
if WheelDelta > 0 then
DBCtrlGrid1.DataSource.Dat
else
DBCtrlGrid1.DataSource.Dat
Handled := True;
end;
why all the exits ?
just use 1 if :
just use 1 if :
if PtInRect(DBCtrlGrid1.ClientRect, DBCtrlGrid1.ScreenToClient(MousePos))
and Assigned(DBCtrlGrid1.DataSource)
and (DBCtrlGrid1.DataSource.DataSet <> nil) then
begin
// ...
ASKER
Sorry.. don't understand...
I need something like this
I need something like this
SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0,@Delta, 0);
if not(PtInRect(DBCtrlGrid1.ClientRect, DBCtrlGrid1.ScreenToClient(MousePos))) then
Exit;
if not Assigned(DBCtrlGrid1.DataSource) then
Exit;
if DBCtrlGrid1.DataSource.DataSet = nil then
Exit;
DBCtrlGrid1.DataSource.DataSet.DisableControls;
if WheelDelta > 0 then
VK_UP
else
VK_DOWN
Handled := True;
@Geert you're right, that's cleanest.
@hrvica5 why do you need to send a key message? Moving the dataset one record up or down take the same effect without using any message. If you hit VK_UP or VK_DOWN the control send a dataset.next or dataset.prior, so, doing it directly, saves one step.
@hrvica5 why do you need to send a key message? Moving the dataset one record up or down take the same effect without using any message. If you hit VK_UP or VK_DOWN the control send a dataset.next or dataset.prior, so, doing it directly, saves one step.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great... Thank you
This is what I need
This is what I need
If so you can use the Form OnMouseWheel event.
Open in new window