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?

有帮助吗?

解决方案

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;
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top