Question

When user press Ctrl+End, VirtualStringTree jumps to the end vertically which is fine but also horizontally. I don't want it to go to the end horizontally. Horizontal scroll should be leaved as is.

How to tell this?

Était-ce utile?

La solution

The OnKeyAction handler in the following code checks if the CTRL + HOME or CTRL + END are pressed and if so, it scrolls (only vertically) either to the top or bottom depending on what was pressed.

procedure TForm1.VirtualTreeKeyAction(Sender: TBaseVirtualTree;
  var CharCode: Word; var Shift: TShiftState; var DoDefault: Boolean);
begin
  if (ssCtrl in Shift) then
  case CharCode of
    VK_HOME:
    begin
      DoDefault := False;
      VirtualTree.ScrollIntoView(VirtualTree.GetFirst, False);
    end;
    VK_END:
    begin
      DoDefault := False;
      VirtualTree.ScrollIntoView(VirtualTree.GetLast, False);
    end;
  end;
end;
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top